Message261479
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. |
|
Date |
User |
Action |
Args |
2016-03-09 21:43:11 | eric.smith | set | recipients:
+ eric.smith, vstinner, docs@python, wolma |
2016-03-09 21:43:11 | eric.smith | set | messageid: <1457559791.36.0.885805084084.issue26506@psf.upfronthosting.co.za> |
2016-03-09 21:43:11 | eric.smith | link | issue26506 messages |
2016-03-09 21:43:11 | eric.smith | create | |
|