list - get element by index vs get with pop() Python -
f.e. have list 1 element
i = ['x']
i - list 1 element
what way more pythonic or performance:
element = i[0]
or
element = i.pop()
we dont care list, if "cut" element pop - no problem us
i[0]
more performant, since has fewer operations carry out.
if there's no reason pop list, why it? that's confusing next programmer looking @ code. use i[0]
.
Comments
Post a Comment