sometype.__new__ and C subclasses
Gregory Ewing
greg.ewing at canterbury.ac.nz
Sun May 2 20:41:29 EDT 2010
James Porter wrote:
> Functions like numpy.zeros_like use ndarray.__new__(subtype,
> ...) to create new arrays based on the shape of other arrays.
>
> Maybe the real answer to this question is "NumPy is doing it wrong"
Yes, I think NumPy is doing it wrong, even for subclasses
written in Python. If the subtype has overridden ndarray's
__new__ method, the way NumPy is doing it will skip the
subclass's version of the method.
--
Greg
More information about the Python-list
mailing list