[Python-Dev] Usage of += on strings in loops in stdlib
Christian Heimes
christian at python.org
Wed Feb 13 00:28:15 CET 2013
More information about the Python-Dev mailing list
Wed Feb 13 00:28:15 CET 2013
- Previous message: [Python-Dev] Usage of += on strings in loops in stdlib
- Next message: [Python-Dev] Usage of += on strings in loops in stdlib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Am 12.02.2013 22:32, schrieb Antoine Pitrou:
> For the record, io.StringIO should be quite fast in 3.3.
> (except for the method call overhead that Guido is complaining
> about :-))
AFAIK it's not the actual *call* of the method that is slow, but rather
attribute lookup and creation of bound method objects. If speed is of
the essence, code can cache the method object locally:
strio = io.StringIO()
write = strio.write
for element in elements:
write(element)
result = strio.getvalue()
Christian
- Previous message: [Python-Dev] Usage of += on strings in loops in stdlib
- Next message: [Python-Dev] Usage of += on strings in loops in stdlib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list