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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -