Re: non-copy slices

2009-11-20 Thread Ajit Kumar
On Thu, Nov 19, 2009 at 8:14 PM, Ethan Furman wrote: >> No I'm well aware that there is no deep copy of the objects and the lists >> only keep references to the objects and in essence they have the same >> objects in there. But this doesn't mean they are the same list. >> Modifications to slices a

Re: non-copy slices

2009-11-19 Thread Ethan Furman
Themis Bourdenas wrote: On Thu, Nov 19, 2009 at 2:44 PM, Ethan Furman > wrote: So "shallow copy" == "new label created for existing object". So is your desired behavior to write back to the original list if your sub-list is modified? In other words, you a

Re: non-copy slices

2009-11-19 Thread Themis Bourdenas
On Thu, Nov 19, 2009 at 2:44 PM, Ethan Furman wrote: > Please don't top post. :) > > So "shallow copy" == "new label created for existing object". > > So is your desired behavior to write back to the original list if your > sub-list is modified? In other words, you are creating a window onto an

Re: non-copy slices

2009-11-19 Thread Rami Chowdhury
On Thu, 19 Nov 2009 02:39:42 -0800, wrote: Second and more importantly it's the performance penalty from allocating a large number of lists produced from the slices and the copy of the references. Ah, I see what you were getting at -- thanks for clarifying. On Thu, Nov 19, 2009 at 3:00

Re: non-copy slices

2009-11-19 Thread Ethan Furman
Please don't top post. :) tbour...@doc.ic.ac.uk wrote: On Thu, Nov 19, 2009 at 3:00 AM, Rami Chowdhury mailto:rami.chowdh...@gmail.com>> wrote: I'm not sure you're understanding the point others have been making. A list item is merely another reference to an existing object -- it

Re: non-copy slices

2009-11-19 Thread Daniel Stutzbach
On Wed, Nov 18, 2009 at 9:00 PM, Rami Chowdhury wrote: > I'm not sure you're understanding the point others have been making. A > list item is merely another reference to an existing object -- it > doesn't copy the object in any way. > It still has to copy the reference, though. That takes O(n)

Re: non-copy slices

2009-11-19 Thread tbourden
No I'm well aware that there is no deep copy of the objects and the lists only keep references to the objects and in essence they have the same objects in there. But this doesn't mean they are the same list. Modifications to slices are not written back to the original list. x = range(5) y = x[1:3]

Re: non-copy slices

2009-11-18 Thread Rami Chowdhury
On Wednesday 18 November 2009 17:47:09 tbour...@doc.ic.ac.uk wrote: > Hi, > > sth == something :) sorry for the abbreviation. I'm talking about the > shallow copy, still it's a copy. I'm not sure you're understanding the point others have been making. A list item is merely another reference to

Re: non-copy slices

2009-11-18 Thread Daniel Stutzbach
On Wed, Nov 18, 2009 at 2:22 PM, Themis Bourdenas < t.bourdena...@imperial.ac.uk> wrote: > It's nothing in the library that completely imitates the slice without the > copies, right? You might be interested in my blist extension type (link below). Syntactically, using a blist is just like using

Re: non-copy slices

2009-11-18 Thread tbourden
Hi, sth == something :) sorry for the abbreviation. I'm talking about the shallow copy, still it's a copy. Unnecessary in my case and the worst part in my scenario is the creation (allocation) and deletion of a very large number of lists of moderate size (a few hundred objects) generated due to sl

Re: non-copy slices

2009-11-18 Thread Ethan Furman
tbour...@doc.ic.ac.uk wrote: Hi, I was looking for a facility similar to slices in python library that would avoid the implicit creation of a new list and copy of elements that is the default behaviour. Instead I'd rather have a lazy iteratable object on the original sequence. Well, in the en

Re: non-copy slices

2009-11-18 Thread Themis Bourdenas
Sth else that I noticed as I started using islice. The name is somewhat misleading. Having the slice part in the name I would expect it to imitate the functionality of normal slices. Random access, sub-slicing etc. However, it is only iteratable. Any particular reasons for that? My guess is that it

Re: non-copy slices

2009-11-18 Thread Terry Reedy
tbour...@doc.ic.ac.uk wrote: Hi, I was looking for a facility similar to slices in python library that would avoid the implicit creation of a new list and copy of elements that is the default behaviour. Instead I'd rather have a lazy iteratable object on the original sequence. Well, in the en

Re: non-copy slices

2009-11-18 Thread tbourden
Ahhh yes! that's exactly it. Thanks for pointing out! Themis On Wed, Nov 18, 2009 at 3:44 PM, Tim Golden wrote: > tbour...@doc.ic.ac.uk wrote: > > Hi, > > > > I was looking for a facility similar to slices in python library that > would > > avoid the implicit creation of a new list and copy of

Re: non-copy slices

2009-11-18 Thread Tim Golden
tbour...@doc.ic.ac.uk wrote: Hi, I was looking for a facility similar to slices in python library that would avoid the implicit creation of a new list and copy of elements that is the default behaviour. Instead I'd rather have a lazy iteratable object on the original sequence. Well, in the end I

non-copy slices

2009-11-18 Thread tbourden
Hi, I was looking for a facility similar to slices in python library that would avoid the implicit creation of a new list and copy of elements that is the default behaviour. Instead I'd rather have a lazy iteratable object on the original sequence. Well, in the end I wrote it myself but I was wond