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

command line - Use qwinsta in PowerShell ISE -

java - Incorrect order of records in M-M relationship in hibernate -

Python website log in: BIG-IP can not find session information in the request -