[Python-Dev] optimization required: .format() is much slower than %

Eric Smith eric+python-dev at trueblade.com
Tue May 27 20:14:35 CEST 2008


Christian Heimes wrote:
> Antoine Pitrou schrieb:
>> In order to avoid memory consumption issues there could be a centralized cache
>> as for regular expressions. It makes it easier to handle eviction based on
>> various parameters, and it saves a few bytes for string objects which are never
>> used as a formatting template.
> 
> Good idea!
> I suggest you hook into the string interning code and use a similar
> approach.

I don't think parsing the strings is where it spends its time.  I think 
the time is spent in object creation, __format__ lookup, and building 
the result.  I'm looking into some of these other optimizations now.



More information about the Python-Dev mailing list