[Numpy-discussion] CASTABLE flag
Charles R Harris
Mon Jan 7 13:13:56 CST 2008
On Jan 7, 2008 12:00 PM, Travis E. Oliphant <firstname.lastname@example.org> wrote:
> Charles R Harris wrote:
> > Hi All,
> > I'm thinking that one way to make the automatic type conversion a bit
> > safer to use would be to add a CASTABLE flag to arrays. Then we could
> > write something like
> > a[...] = typecast(b)
> > where typecast returns a view of b with the CASTABLE flag set so that
> > the assignment operator can check whether to implement the current
> > behavior or to raise an error. Maybe this could even be part of the
> > dtype scalar, although that might cause a lot of problems with the
> > current default conversions. What do folks think?
> That is an interesting approach. The issue raised of having to
> convert lines of code that currently work (which does implicit casting)
> would still be there (like ndimage), but it would not cause unnecessary
> data copying, and would help with this complaint (that I've heard before
> and have some sympathy towards).
> I'm intrigued.
Maybe we could also set a global flag, typesafe, that in the current Numpy
version would default to false, giving current behavior, but could be set
true to get the new behavior. Then when Numpy 1.1 comes out we could make
the global default true. That way folks could keep the current code working
until they are ready to use the typesafe feature.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion