[Chandler-dev] Minor perf tip

Heikki Toivonen heikki at osafoundation.org
Wed Apr 18 23:11:33 PDT 2007


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : http://lists.osafoundation.org/pipermail/chandler-dev/attachments/20070418/bb93a2b2/signature.pgp


More information about the chandler-dev mailing list