Re: [Python-Dev] implementation of copy standard lib

2005-08-16 Thread Simon Brunning
On 8/14/05, Martijn Brouwer <[EMAIL PROTECTED]> wrote: > After profiling a small python script I found that approximately 50% of > the runtime of my script was consumed by one line: "import copy". > Another 15% was the startup of the interpreter, but that is OK for an > interpreted language. The co

Re: [Python-Dev] implementation of copy standard lib

2005-08-16 Thread Michael Hoffman
Simon Brunning wrote: > I think that copy is very rarely used. I don't think I've ever imported it. > > Or is it just me? It's just you. I use copy.deepcopy() fairly often. -- Michael Hoffman -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] implementation of copy standard lib

2005-08-16 Thread Benji York
Simon Brunning wrote: > I think that copy is very rarely used. I don't think I've ever imported it. > > Or is it just me? I rarely use copy, and almost always regret it when I do. -- Benji York -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] implementation of copy standard lib

2005-08-16 Thread Ron Adam
Simon Brunning wrote: > On 8/14/05, Martijn Brouwer <[EMAIL PROTECTED]> wrote: > >>After profiling a small python script I found that approximately 50% of >>the runtime of my script was consumed by one line: "import copy". >>Another 15% was the startup of the interpreter, but that is OK for an >>

Re: [Python-Dev] implementation of copy standard lib

2005-08-17 Thread Simon Brunning
On 8/16/05, Martijn Brouwer <[EMAIL PROTECTED]> wrote: > Well, I guess making a deep copy of an object is important in many case. > Just try this: > A=[] > B=A > A.append("foo") > print B > > Guess the output. It is: > ['foo'] I remember thinking that this behavior was odd when I learned Java man

Re: [Python-Dev] implementation of copy standard lib

2005-08-17 Thread Michael Hudson
Simon Brunning <[EMAIL PROTECTED]> writes: > I think that copy is very rarely used. I don't think I've ever imported it. > > Or is it just me? Not really. I've used it once that I can recall, to copy a kind of generic "default value", something like: def value(self, v, default): if hasattr(

Re: [Python-Dev] implementation of copy standard lib

2005-08-17 Thread Ron Adam
Michael Hudson wrote: > Simon Brunning <[EMAIL PROTECTED]> writes: > > >>I think that copy is very rarely used. I don't think I've ever imported it. >> >>Or is it just me? > > > Not really. I've used it once that I can recall, to copy a kind of > generic "default value", something like: > > d

List copying idiom was Re: [Python-Dev] implementation of copy standard lib

2005-08-16 Thread Tom Anderson
On Tue, 16 Aug 2005, Ron Adam wrote: > Simon Brunning wrote: > >> On 8/14/05, Martijn Brouwer <[EMAIL PROTECTED]> wrote: >> >>> I can imagine that *a lot* of libs/scripts use the copy library, >> >> I think that copy is very rarely used. I don't think I've ever imported it. > > I use copy.deepco

'import copy' too slow?, was Re: [Python-Dev] implementation of copy standard lib

2005-08-16 Thread Peter Otten
[Martijn Brouwer] > Importing copy takes 5-10 times more time that > import os, string and re together! Are you sure you aren't seeing the effects of caching? My little ad hoc test (which fails on the os module) doesn't confirm your numbers: $ python2.4 -m timeit -n1 -r1 -s"import sys; assert 're

Re: List copying idiom was Re: [Python-Dev] implementation of copy standard lib

2005-08-16 Thread John Machin
Tom Anderson wrote: > > When you say [:], do you mean that you copy lists like this: > > l = someList() > m = [] > m[:] = l > > ? Why not m = L[:] instead of m = []; m[:] = L ??? > > That's what i've been doing. The other day, i realised that i could just > do: > > l = someList() > m = list

Re: List copying idiom was Re: [Python-Dev] implementation of copy standard lib

2005-08-17 Thread Steve Holden
Tom Anderson wrote: > On Tue, 16 Aug 2005, Ron Adam wrote: > > >>Simon Brunning wrote: >> >> >>>On 8/14/05, Martijn Brouwer <[EMAIL PROTECTED]> wrote: >>> >>> I can imagine that *a lot* of libs/scripts use the copy library, >>> >>>I think that copy is very rarely used. I don't think I've ever

Re: List copying idiom was Re: [Python-Dev] implementation of copy standard lib

2005-08-17 Thread Tom Anderson
On Wed, 17 Aug 2005, Steve Holden wrote: > Tom Anderson wrote: > >> On Tue, 16 Aug 2005, Ron Adam wrote: >> >>> Simon Brunning wrote: >>> On 8/14/05, Martijn Brouwer <[EMAIL PROTECTED]> wrote: > I can imagine that *a lot* of libs/scripts use the copy library, I think th

Re: 'import copy' too slow?, was Re: [Python-Dev] implementation of copy standard lib

2005-08-16 Thread Peter Otten
[Martijn Brouwer] > Importing copy takes 5-10 times more time that > import os, string and re together! If your measurement isn't flawed, try again after replacing the following import in copy.py try: from org.python.core import PyStringMap except ImportError: PyStringMap = None with jus