[Python-Dev] Usage of += on strings in loops in stdlib (original) (raw)
Amaury Forgeot d'Arc amauryfa at gmail.com
Wed Feb 13 15:47:45 CET 2013
- Previous message: [Python-Dev] Usage of += on strings in loops in stdlib
- Next message: [Python-Dev] Usage of += on strings in loops in stdlib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2013/2/13 Christian Tismer <tismer at stackless.com>
On 13.02.13 15:27, Amaury Forgeot d'Arc wrote:
2013/2/13 Lennart Regebro <regebro at gmail.com> On Wed, Feb 13, 2013 at 1:10 PM, Serhiy Storchaka <storchaka at gmail.com> wrote: > I prefer "x = '%s%s%s%s' % (a, b, c, d)" when string's number is more than 3 > and some of them are literal strings.
This has the benefit of being slow both on CPython and PyPy. Although using .format() is even slower. :-) Did you really try it? PyPy is really fast with str.mod, when the format string is a constant. Yes, it's jitted. How about the .format() style: Is that jitted as well? In order to get people to prefer .format over mod, it would be nice if PyPy made this actually faster :-)
.format() is jitted as well. But it's still slower than str.mod (about 25%) I suppose it can be further optimized.
-- Amaury Forgeot d'Arc -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130213/c5f6017a/attachment.html>
- Previous message: [Python-Dev] Usage of += on strings in loops in stdlib
- Next message: [Python-Dev] Usage of += on strings in loops in stdlib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]