[Python-Dev] [numpy wishlist] Interpreter support for temporary elision in third-party classes

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Jun 6 04:26:35 CEST 2014


Nathaniel Smith wrote:

> I'd be a 
> little nervous about whether anyone has implemented, say, an iadd with 
> side effects such that you can tell whether a copy was made, even if the 
> object being copied is immediately destroyed.

I can think of at least one plausible scenario where
this could occur: the operand is a view object that
wraps another object, and its __iadd__ method updates
that other object.

In fact, now that I think about it, exactly this
kind of thing happens in numpy when you slice an
array!

So the opt-in indicator would need to be dynamic, on
a per-object basis, rather than a type flag.

-- 
Greg


More information about the Python-Dev mailing list