Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Nick Coghlan
On Wed, Feb 13, 2013 at 5:42 PM, Alexandre Vassalotti wrote: > On Tue, Feb 12, 2013 at 5:25 PM, Christian Tismer > wrote: >> >> Would ropes be an answer (and a simple way to cope with string mutation >> patterns) as an alternative implementation, and therefore still justify >> the usage of that p

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Alexandre Vassalotti
On Tue, Feb 12, 2013 at 5:25 PM, Christian Tismer wrote: > Would ropes be an answer (and a simple way to cope with string mutation > patterns) as an alternative implementation, and therefore still justify > the usage of that pattern? > I don't think so. Ropes are really useful when you work with

Re: [Python-Dev] efficient string concatenation (yep, from 2004)

2013-02-12 Thread Lennart Regebro
> Something is needed - a patch for PyPy or for the documentation I guess. Not arguing that it wouldn't be good, but I disagree that it is needed. This is only an issue when you, as in your proof, have a loop that does concatenation. This is usually when looping over a list of strings that should

Re: [Python-Dev] [pypy-dev] efficient string concatenation (yep, from 2004)

2013-02-12 Thread Maciej Fijalkowski
Hi Christian. We have it, just not enabled by default. --objspace-with-strbuf I think On Wed, Feb 13, 2013 at 1:53 AM, Christian Tismer wrote: > Hi friends, > > efficient string concatenation has been a topic in 2004. > Armin Rigo proposed a patch with the name of the subject, > more precisely:

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Antoine Pitrou
On Wed, 13 Feb 2013 08:16:21 +0100 Antoine Pitrou wrote: > On Wed, 13 Feb 2013 09:39:23 +1000 > Nick Coghlan wrote: > > On 13 Feb 2013 07:08, "Maciej Fijalkowski" wrote: > > > > > > Hi > > > > > > We recently encountered a performance issue in stdlib for pypy. It > > > turned out that someone co

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Antoine Pitrou
On Wed, 13 Feb 2013 09:39:23 +1000 Nick Coghlan wrote: > On 13 Feb 2013 07:08, "Maciej Fijalkowski" wrote: > > > > Hi > > > > We recently encountered a performance issue in stdlib for pypy. It > > turned out that someone commited a performance "fix" that uses += for > > strings instead of "".join

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Antoine Pitrou
On Wed, 13 Feb 2013 00:28:15 +0100 Christian Heimes wrote: > Am 12.02.2013 22:32, schrieb Antoine Pitrou: > > For the record, io.StringIO should be quite fast in 3.3. > > (except for the method call overhead that Guido is complaining > > about :-)) > > AFAIK it's not the actual *call* of the meth

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Terry Reedy
On 2/12/2013 4:03 PM, Maciej Fijalkowski wrote: Hi We recently encountered a performance issue in stdlib for pypy. It turned out that someone commited a performance "fix" that uses += for strings instead of "".join() that was there before. Now this hurts pypy (we can mitigate it to some degree

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Terry Reedy
On 2/12/2013 6:20 PM, MRAB wrote: Tuples are much like immutable lists; sets were added, and then frozensets; should we be adding mutable strings too (a bit like C#'s StringBuilder)? (Just wondering...) StringIO is effectively a mutable string with a file interface. sio.write('abc') is the equ

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Christian Tismer
On 13.02.13 02:09, Alexandre Vassalotti wrote: On Tue, Feb 12, 2013 at 1:44 PM, Antoine Pitrou > wrote: It's idiomatic because strings are immutable (by design, not because of an optimization detail) and therefore concatenation *has* to imply building

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Christian Tismer
On 12.02.13 22:03, Maciej Fijalkowski wrote: Hi We recently encountered a performance issue in stdlib for pypy. It turned out that someone commited a performance "fix" that uses += for strings instead of "".join() that was there before. Now this hurts pypy (we can mitigate it to some degree tho

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Alexandre Vassalotti
On Tue, Feb 12, 2013 at 1:44 PM, Antoine Pitrou wrote: > It's idiomatic because strings are immutable (by design, not because of > an optimization detail) and therefore concatenation *has* to imply > building a new string from scratch. > Not necessarily. It is totally possible to implement strin

[Python-Dev] efficient string concatenation (yep, from 2004)

2013-02-12 Thread Christian Tismer
Hi friends, _efficient string concatenation_ has been a topic in 2004. Armin Rigo proposed a patch with the name of the subject, more precisely: /[Patches] [ python-Patches-980695 ] efficient string concatenation// //on sourceforge.net, on 2004-06-28.// / This patch was finally added to Python 2

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Nick Coghlan
On 13 Feb 2013 07:08, "Maciej Fijalkowski" wrote: > > Hi > > We recently encountered a performance issue in stdlib for pypy. It > turned out that someone commited a performance "fix" that uses += for > strings instead of "".join() that was there before. > > Now this hurts pypy (we can mitigate it

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Maciej Fijalkowski
On Wed, Feb 13, 2013 at 1:20 AM, MRAB wrote: > On 2013-02-12 21:44, Antoine Pitrou wrote: >> >> On Tue, 12 Feb 2013 16:40:38 -0500 >> Ned Batchelder wrote: >>> >>> >>> But the only reason "".join() is a Python idiom in the first place is >>> because it was "the fast way" to do what everyone initi

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Maciej Fijalkowski
On Wed, Feb 13, 2013 at 1:28 AM, Christian Heimes wrote: > Am 12.02.2013 22:32, schrieb Antoine Pitrou: >> For the record, io.StringIO should be quite fast in 3.3. >> (except for the method call overhead that Guido is complaining >> about :-)) > > AFAIK it's not the actual *call* of the method tha

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Christian Heimes
Am 12.02.2013 22:32, schrieb Antoine Pitrou: > For the record, io.StringIO should be quite fast in 3.3. > (except for the method call overhead that Guido is complaining > about :-)) AFAIK it's not the actual *call* of the method that is slow, but rather attribute lookup and creation of bound metho

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread MRAB
On 2013-02-12 21:44, Antoine Pitrou wrote: On Tue, 12 Feb 2013 16:40:38 -0500 Ned Batchelder wrote: But the only reason "".join() is a Python idiom in the first place is because it was "the fast way" to do what everyone initially coded as "s += ...". Just because we all learned a long time a

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Xavier Morel
On 2013-02-12, at 22:40 , Ned Batchelder wrote: > But the only reason "".join() is a Python idiom in the first place is because > it was "the fast way" to do what everyone initially coded as "s += ...". > Just because we all learned a long time ago that joining was the fast way to > build a st

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Antoine Pitrou
On Tue, 12 Feb 2013 16:40:38 -0500 Ned Batchelder wrote: > > But the only reason "".join() is a Python idiom in the first place is > because it was "the fast way" to do what everyone initially coded as "s > += ...". Just because we all learned a long time ago that joining was > the fast way

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread R. David Murray
On Tue, 12 Feb 2013 16:40:38 -0500, Ned Batchelder wrote: > On 2/12/2013 4:16 PM, Brett Cannon wrote: > > On Tue, Feb 12, 2013 at 4:06 PM, Antoine Pitrou > > wrote: > > On Tue, 12 Feb 2013 23:03:04 +0200 > > Maciej Fijalkowski mailto:fij...@gmail.com>> wrote:

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Ned Batchelder
On 2/12/2013 4:16 PM, Brett Cannon wrote: On Tue, Feb 12, 2013 at 4:06 PM, Antoine Pitrou > wrote: Hi ! On Tue, 12 Feb 2013 23:03:04 +0200 Maciej Fijalkowski mailto:fij...@gmail.com>> wrote: > > We recently encountered a performance issue in

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Antoine Pitrou
On Tue, 12 Feb 2013 13:32:50 -0800 "fwierzbi...@gmail.com" wrote: > On Tue, Feb 12, 2013 at 1:03 PM, Maciej Fijalkowski wrote: > > Hi > > > > We recently encountered a performance issue in stdlib for pypy. It > > turned out that someone commited a performance "fix" that uses += for > > strings in

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread fwierzbi...@gmail.com
On Tue, Feb 12, 2013 at 1:03 PM, Maciej Fijalkowski wrote: > Hi > > We recently encountered a performance issue in stdlib for pypy. It > turned out that someone commited a performance "fix" that uses += for > strings instead of "".join() that was there before. > > Now this hurts pypy (we can mitig

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Maciej Fijalkowski
On Tue, Feb 12, 2013 at 11:16 PM, Brett Cannon wrote: > > > > On Tue, Feb 12, 2013 at 4:06 PM, Antoine Pitrou wrote: >> >> >> Hi ! >> >> On Tue, 12 Feb 2013 23:03:04 +0200 >> Maciej Fijalkowski wrote: >> > >> > We recently encountered a performance issue in stdlib for pypy. It >> > turned out th

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Brett Cannon
On Tue, Feb 12, 2013 at 4:06 PM, Antoine Pitrou wrote: > > Hi ! > > On Tue, 12 Feb 2013 23:03:04 +0200 > Maciej Fijalkowski wrote: > > > > We recently encountered a performance issue in stdlib for pypy. It > > turned out that someone commited a performance "fix" that uses += for > > strings inst

Re: [Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Antoine Pitrou
Hi ! On Tue, 12 Feb 2013 23:03:04 +0200 Maciej Fijalkowski wrote: > > We recently encountered a performance issue in stdlib for pypy. It > turned out that someone commited a performance "fix" that uses += for > strings instead of "".join() that was there before. > > Now this hurts pypy (we can

[Python-Dev] Usage of += on strings in loops in stdlib

2013-02-12 Thread Maciej Fijalkowski
Hi We recently encountered a performance issue in stdlib for pypy. It turned out that someone commited a performance "fix" that uses += for strings instead of "".join() that was there before. Now this hurts pypy (we can mitigate it to some degree though) and possible Jython and IronPython too. H

Re: [Python-Dev] what is a dict_keys and where can I import it from?

2013-02-12 Thread Amaury Forgeot d'Arc
2013/2/12 Steven D'Aprano > An anomaly, which I cannot explain: > > py> issubclass(type(keys), KeysView) > True > py> type(keys) is KeysView > False > py> type(keys).__mro__ > (, ) > > > This disturbs my calm, because I expect that if issubclass returns True, > the two classes will either be iden

Re: [Python-Dev] what is a dict_keys and where can I import it from?

2013-02-12 Thread Steven D'Aprano
On 12/02/13 18:05, Chris Withers wrote: Hi all, So, dicts in Python 3 return "something different" from their keys and values methods: >> dict(x=1, y=2).keys() dict_keys(['y', 'x']) >> type(dict(x=1, y=2).keys()) I have vague memories of these things being referred to as views or some su

Re: [Python-Dev] Question regarding: Lib/_markupbase.py

2013-02-12 Thread Antoine Pitrou
Le Mon, 11 Feb 2013 11:02:04 -0800, Guido van Rossum a écrit : > Warning: see http://bugs.python.org/issue17170. Depending on the > length of the string being scanned and the probability of finding the > specific character, the proposed change could actually be a > *pessimization*. OTOH if the cha

Re: [Python-Dev] what is a dict_keys and where can I import it from?

2013-02-12 Thread Andrew Svetlov
Is collections.KeysView good for you? On Tue, Feb 12, 2013 at 9:05 AM, Chris Withers wrote: > Hi all, > > So, dicts in Python 3 return "something different" from their keys and > values methods: > dict(x=1, y=2).keys() > dict_keys(['y', 'x']) type(dict(x=1, y=2).keys()) > > > I have va

[Python-Dev] what is a dict_keys and where can I import it from?

2013-02-12 Thread Chris Withers
Hi all, So, dicts in Python 3 return "something different" from their keys and values methods: >>> dict(x=1, y=2).keys() dict_keys(['y', 'x']) >>> type(dict(x=1, y=2).keys()) I have vague memories of these things being referred to as views or some such? Where can I learn more? More import