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

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


Nathaniel Smith wrote:

I.e., BINADD could do

if (PyREFCNT(left) == 1) result = PyNumberInPlaceAdd(left, right); else result = PyNumberAdd(left, right) Upside: all packages automagically benefit! Potential downsides to consider: - Subtle but real and user-visible change in Python semantics.

That would be a real worry. Even if such cases were rare, they'd be damnably difficult to debug when they did occur.

I think for safety's sake this should only be done if the type concerned opts in somehow, perhaps by a tp_flag indicating that the type is eligible for temporary elision.

-- Greg



More information about the Python-Dev mailing list