This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.smith
Recipients docs@python, eric.smith, vstinner, wolma
Date 2016-03-09.21:43:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1457559791.36.0.885805084084.issue26506@psf.upfronthosting.co.za>
In-reply-to
Content
Without lots of analysis (and disassembly), I can't speak to how valid your tests are, but they don't seem unreasonable.

format() will always be slower, because it's more general (primarily in that it can be extended to new types). Plus, it involves at least a name lookup that %-formatting can skip. The usual ways to optimize this lookup holds here, too, if speed is really that critical (which I'm skeptical of).

For example, say you had a custom type which implemented __format__ to understand the "X" format code. Using format(), this type could format itself as hex. %-formatting can't do that.

In any event, I don't think we want to promulgate the fastest way to do a hex conversion, just the clearest.

I can't say why format() in 3.5 is slower. There are many changes and tracking it down would be quite time consuming.
History
Date User Action Args
2016-03-09 21:43:11eric.smithsetrecipients: + eric.smith, vstinner, docs@python, wolma
2016-03-09 21:43:11eric.smithsetmessageid: <1457559791.36.0.885805084084.issue26506@psf.upfronthosting.co.za>
2016-03-09 21:43:11eric.smithlinkissue26506 messages
2016-03-09 21:43:11eric.smithcreate