-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The epic dtype cleanup plan #2899
Comments
Cool writeup! On Jan 9, 2013, at 7:21 PM, njsmith wrote:
-Travis
|
@teoliphant: Another of the secret goals is enabling us to eventually get rid of scalar types entirely in favor of 0-d ndarrays, as explored in this long email: http://mail.scipy.org/pipermail/numpy-discussion/2013-January/064995.html That's a good point about dual inheritance though -- I wonder how important that is. Certainly it would take some extreme trickery to have
We could have ndarray_int, ndarray_float types that were just ndarray-plus-a-nominal-inheritance-from-{int,float}, but the problem is that a single array over its lifetime can convert from 0-d to multi-dimensional, and can convert from float to int and vice-versa. OTOH CPython does allow you to change the type of an object in-place, so this is possible...
Really in the long run it would be nice if the one-and-only-one way to do these kinds of checks was something like |
Sorry. Stupid buttons. |
Hi. I was doing some dtype stuff today and noticed some weridness in dtype construction (http://docs.scipy.org/doc/numpy/user/basics.rec.html#defining-structured-arrays). The dtype constructor argument is interpreted differently depending on whether it is a list or tuple. Ouch! This is very confusing as sequence types (list, tuple) are typically interpreted in the same way. Is there a backwards-incompatibility release in the horizon where this could be fixed? |
I am going to close this. I went through the list of above changes, and either there are more specific open issues, or they are on the TODO list (i.e. the current state of gh-14422 includes the goal of Python objects, ). It also links here (and if not, I will fix that). pydata/xarray#1262 is an interesting issue on xarray to list as motivation. |
[this is very drafty notes-to-self that I'm hitting save on now because I was dumb and typed it into a webform where it might get lost, and because I'm lazy and don't want to pull it out to stick in some file on my hard-drive where I'll lose it. So no guarantees any of this actually makes sense or anything, but since we've been running into a number of nasty aspects of dtypes recently I wanted to write down a bunch of ideas together so we can try and organize them somewhat. Feel free to comment even at this early date. Also, don't tell anyone, but part of the secret goal here is enabling the NA dtype work too (though not all of this is a prerequisite for that by any means).]
End goal: dtypes basically function like Python objects WRT to subclassing etc.; isinstance/issubclass work in a useful way; parametric dtypes are not horrible; user-defined dtypes are on closer-to-equal footing with built-in dtypes
type
and define__instancecheck__
and__subclasscheck__
methods, soisinstance(foo, dtype_instance)
can do something useful. (This will completely change the dtype struct's memory layout though,type
is a huge object, and all of dtype's fields will get shifted down in memory.)self
arguments. Turn them into the equivalent of cpdef methods. (not sure how we make this work -- follow MRO when doing dtype operations? or in dtype.new, copy parent fn ptrs to undefined child fn ptrs and ha ha no multiple inheritance is not supported?)if (!(arg = CheckOrConvertThisDtypeThing(arg)) return -1;
, and that function sets up a new-style dtype in place of the old-style one, while raising a DeprecationWarning. This might not be so horrible even, though we would want to make sure we did all the binary compatibility breaking changes at once. (This still won't help for user code that reaches into dtype objects by hand, though, as opposed to just creating them. It's possible that all user dtypes do this, so eh.)Note: there is an argument for getting all the dtype struct changes out of the way before exposing them to ufunc inner loops, since that will open the door to more user code that depends on the contents of dtype structs. Of course if the problem is already as bad as it could possibly be, then this doesn't matter :-). And letting ufuncs get at dtypes is probably the single biggest win on this list, so it would be nice to prioritize it.
The text was updated successfully, but these errors were encountered: