[Numpy-discussion] Changes in PyArray_FromAny between 1.5.x and 1.6.x

Travis Oliphant travis at continuum.io
Tue Jun 5 23:15:28 EDT 2012

> I don't think that would work, because looking more closely, I don't
> think they're actually doing anything like what
> __array_interface__/PEP3118 are designed for. They just have some
> custom class ("sage.rings.real_mpfr.RealLiteral", I guess an arbitrary
> precision floating point of some sort?), and they want instances that
> are passed to np.array() to be automatically coerced to another type
> (float64) by default. But there's no buffer sharing or anything like
> that going on at all. Mike, does that sound right?
> This automagic coercion seems... in very dubious taste to me. (Why
> does creating an array object imply that you want to throw away
> precision? You can already throw away precision explicitly by doing
> np.array(f, dtype=float).) But if this automatic coercion feature is
> useful, then wouldn't it be better to have a different interface
> instead of kluging it into __array_interface__, like we should check
> for an attribute called __numpy_preferred_dtype__ or something?

Interesting.  It does look like off-label use of the __array_interface__ attribute.   Given that "array" used to query the __array_interface__ attribute for type discovery, I still wonder why it was disabled in 1.6? 


More information about the NumPy-Discussion mailing list