Pointers/References in Python?

boblatest at googlemail.com boblatest at googlemail.com
Wed Jul 30 10:46:37 EDT 2008


Hello,

I have a long list of memory-heavy objects that I would like to access
in differently sorted order. Let's say I'd like to have lists called
by_date or by_size that I can use to access the objects in the
specified order.

Of course I can just build those lists naively by creating copies of
the original list and then sorting them according to my wishes. But
that would create huge memory overhead. Of course I could use lists of
indices into the "master" list, just as in C I'd create lists or
arrays of pointers into the original data.

Is there a clever Python way to do this, or should I just use lists of
indices?

I know there is a thing called "shallow copy" that has something to do
with not duplicating memory content but I don't understand the
concept. Maybe that's what would help here, too.

Thanks,
robert



More information about the Python-list mailing list