Message180452
I think ''.join() will always be faster than ''.format(), for a number of reasons (some already stated):
- it doesn't have to pass the format string
- it doesn't have to do the __format__ lookup and call the resulting function (although I believe there's an optimization for str)
- it doesn't have to consider the conversion and formatting steps
Whether b''.format() would have to lookup and call __format__ remains to be seen. From what I've read, maybe baking in knowledge of bytes, float, and int would be good enough. I suspect there might be some need for datetimes, but I could be wrong.
The above said, code using b''.format() would definitely be easier to write and understand that a lot of individual field formatting followed by a .join(). |
|
Date |
User |
Action |
Args |
2013-01-23 09:36:15 | eric.smith | set | recipients:
+ eric.smith, gvanrossum, loewis, terry.reedy, exarkun, pitrou, vstinner, christian.heimes, benjamin.peterson, glyph, ezio.melotti, arjennienhuis, uau, martin.panter, serhiy.storchaka |
2013-01-23 09:36:15 | eric.smith | set | messageid: <1358933775.67.0.0763907415483.issue3982@psf.upfronthosting.co.za> |
2013-01-23 09:36:15 | eric.smith | link | issue3982 messages |
2013-01-23 09:36:15 | eric.smith | create | |
|