Suppose you have a list (may generalize to tuple etc. but haven't tested):

l = [1, 2]

and you are interested in the first (may generalize to others but
haven't tested) item from it, it is 3-5% faster to do:

a = l[0]

compared to

a, dummy = l

The difference is likely bigger if you have a longer list and you are
just interested in one of them vs. getting all of them with bunch of
dummies like in the latter sample.

When I was analyzing a pylint log looking for unused variables I
stumbled into lots of places that could potentially benefit a little bit
by just taking the elements that are needed from a list/tuple/... I did
not check if any of that code is on critical path, but if you see them
in profiles that is one place you can save a little.

-- 
  Heikki Toivonen


Attachment: signature.asc
Description: OpenPGP digital signature

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Open Source Applications Foundation "chandler-dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/chandler-dev

Reply via email to