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 wolma
Recipients docs@python, eric.smith, vstinner, wolma
Date 2016-03-10.17:25:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1457630759.83.0.924095184001.issue26506@psf.upfronthosting.co.za>
In-reply-to
Content
> Hum, python3 looks faster on this dummy microbenchmark yeah. Who said that Python 3 is slower? :-)

If you're alluding to that seemingly endless thread over on python-list, let me say that it is not my motivation to start anything like that here. Sorry also if I sort of hijacked your documentation issue with my performance question.

I really only wondered whether there would be any argument for or against any of the two versions (%-interpolation, format-based) other than stylistic ones.
That's why I ran the micro-benchmark and, in fact, I was expecting %-interpolation to be faster exactly because it is less flexible.
What I am surprised by is not the fact that %-interpolation got faster in Python3, but the fact that format didn't.
I was wondering whether %-interpolation maybe takes some fast path in Python3 that simply wasn't implemented for format. If that was the case it could have been rewarding to just optimize format the same way.
As I know Victor is working on performance stuff I thought I'd just ask here, but from your answer I gather that things are rather not so simple and that's ok.

> I wrote a first article to explain my work on optimization:
https://haypo.github.io/pybyteswriter.html

Thanks for the link.

> str.format(args) was also optimized, but it's still faster than str%args.

You mean slower I assume ?

> Hum, I don't recall why you started to talk about performance :-D

See above.

> Why not documenting "%x" % value *and* format(value, 'x')?

> I prefer "%x" % value. I never use format(value, ...) but sometimes I use "{0:x}".format(value).

I prefer the last version, use the first sometimes, but documenting several ways seems reasonable.
History
Date User Action Args
2016-03-10 17:25:59wolmasetrecipients: + wolma, vstinner, eric.smith, docs@python
2016-03-10 17:25:59wolmasetmessageid: <1457630759.83.0.924095184001.issue26506@psf.upfronthosting.co.za>
2016-03-10 17:25:59wolmalinkissue26506 messages
2016-03-10 17:25:59wolmacreate