On Wed, Feb 13, 2013 at 1:28 AM, Christian Heimes <christ...@python.org> wrote: > 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()
And this is a great example of muddying code in stdlib for the sake of speeding up CPython. Cheers, fijal _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com