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
scalar does not inherit byteorder from the array it's "created" from (Trac #1268) #1866
Comments
@pv wrote on 2010-10-10 It seems (cf. arrayscalars.h) that the scalar objects do not even have byte order on the C level, they're just assumed to be native. |
Milestone changed to |
I have just been bitten by this in a context where I wanted to play with bits. Another example:
I think this behaviour needs to be documented at http://docs.scipy.org/doc/numpy/user/basics.byteswapping.html EDIT (@seberg): The above documentation note has been added in the meantime. |
DOC note the effect of #1866 in byteorder discussion
Turning this into a documentation issue. Edit: we will not change behaviour, but we should document it. |
Can anyone (@seberg?) either help me find the original ticket (now showing a 404) or figuring out what to document? Thanks! |
@melissawm the original ticket only has the same information as shown here AFAIK (I think the track is lost in time, at least I do not know who might still have the data). There is a warning here now: https://numpy.org/doc/stable/user/basics.byteswapping.html (a bit down the page). Maybe that is just enough? Scalars are always stored as native-byteorder, so indexing, etc. can "swap" if the result is a scalar. OTOH, also ufuncs never "preserve" byte-order, so losing the byte-order information is not that uncommon anyway. We could probably drop the "currently", I don't really see this changing any time soon (there is probably semi-public API that would even break, anyway). |
We don't preserve non-native byte-order and we have no wish to do so. (If someone disagrees, they better wite a NEP ;)) Spell it out, and thus: closes numpygh-1866
Original ticket http://projects.scipy.org/numpy/ticket/1268 on 2009-10-20 by @mdboom, assigned to unknown.
This may in fact be correct behavior, but it can lead to confusing use of byteswap, since the following is not guaranteed:
and for that matter, neither is:
(This bug began as part of #1857, but is probably a different bug.)
The text was updated successfully, but these errors were encountered: