Are lists at least as efficient as dictionaries?
Jp Calderone
exarkun at intarweb.us
Sat Aug 30 03:03:03 EDT 2003
On Fri, Aug 29, 2003 at 10:24:37AM -0700, Chad Netzer wrote:
> On Fri, 2003-08-29 at 07:54, Jp Calderone wrote:
>
> > += could simply be syntactic sugar for a call to __add__ and then an
> > assignment. This would work for mutable and immutable objects.
>
> But it loses the advantage that some objects would otherwise have of
> being able to mutate in place, without allocating a new object (ie. very
> large matrix additions).
>
But as you removed from my original post, list.extend() exists. All one
has to do to retain the existing functionality of __iadd__ is name the
method something else, then call it. All the advantages, none of the
confusing or difficult to track semantics.
Jp
More information about the Python-list
mailing list