[Python-Dev] Ridiculously minor tweaks?

M.-A. Lemburg mal@lemburg.com
Wed, 12 Mar 2003 10:01:32 +0100


Guido van Rossum wrote:
>>There are many places in the standard library where some code either
>>iterates over a literal list or checks for membership in a literal
>>list.  I'm curious if it would be considered productive and useful
>>to go through and change those places to iterate over/check for
>>membership in literal tuples instead fo lists.  The tuple, I think,
>>more closely reflects the read-only literal nature of the code and
>>is slightly faster to boot.
> 
> 
> -1.
> 
> I bet you can't prove the speed-up.

He probably can :-) That's why I have so many tools in mxTools
which return tuples instead of lists, e.g. trange() and indices().
Both the tuple creation and the iteration are faster than list
creation and access (tuples don't use indirection which saves you a
second malloc() and dereference).

As always: it's the sum of small tweaks like these that makes the
difference in the overall performance of an application.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Software directly from the Source  (#1, Mar 12 2003)
 >>> Python/Zope Products & Consulting ...         http://www.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________
Python UK 2003, Oxford:                                     20 days left
EuroPython 2003, Charleroi, Belgium:                       104 days left