non-copy slices
Ethan Furman
ethan at stoneleaf.us
Thu Nov 19 19:08:36 EST 2009
Themis Bourdenas wrote:
> On Thu, Nov 19, 2009 at 2:44 PM, Ethan Furman <ethan at stoneleaf.us
> <mailto:ethan at stoneleaf.us>> 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 are creating a window onto an
> existing list? If not, what would happen when a sublist element was
> modified (or deleted, or appended, or ...)?
>
> ~Ethan~
>
> Yes a window / view on the existing list describes it best. So every
> modification you make in this view is actually modifying the original
> list accordingly. Blist that was suggested in a previous email in the
> thread seems lightweight but it does create a new list when a
> modification is made. In any case, I've already implemented the object
> myself and I can post it if you care to have a look, but I was just
> wondering if there was already something in the standard library.
>
> Themis
Unfortunately, I am not very familiar with the stdlib yet (gotta buy
that book!). I'm going to guess 'No' since nobody has chimed in with a
'Yes', though.
I'd love to see what you have for that. Does in support a stepped
window, or only contiguous sequences? The one I put together this
afternoon only does contiguous sequences, as I had no use cases to
decide how assignments of multiple items should be handled, and not a
lot of time to implement something generic -- so, to answer John's
question from a completely different thread, yes I do enjoy working on
small projects even if IAGNI. :)
Cheers!
~Ethan~
More information about the Python-list
mailing list