[issue24313] json fails to serialise numpy.int64

2022-02-23 Thread Nikolay Markov
Nikolay Markov added the comment: Just ran into this. Are there any updates? Is there any task to contribute to regarding this? -- nosy: +mxposed ___ Python tracker ___

[issue24313] json fails to serialise numpy.int64

2019-10-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: We could use __index__ for serializing numpy.int64. But what to do with numpy.float32 and numpy.float128? It is a part of a much larger problem (which includes other numbers, collections, encoded strings, named tuples and data classes, etc). I am working

[issue24313] json fails to serialise numpy.int64

2019-10-22 Thread Batuhan
Batuhan added the comment: What is the next step of this 4-year-old issue? I think i can prepare a patch for using __index__ (as suggested by @r.david.murray) -- nosy: +BTaskaya ___ Python tracker

[issue24313] json fails to serialise numpy.int64

2019-08-26 Thread Vicki Brown
Vicki Brown added the comment: Note also that pandas DataFrame.to_json() method has no issue with int64. Perhaps you could borrow their code. -- ___ Python tracker ___

[issue24313] json fails to serialise numpy.int64

2019-08-26 Thread Vicki Brown
Vicki Brown added the comment: This is still broken. With pandas being popular, it's more likely someone might hit it. Can we fix this? At the very least, the error message needs to be made much more specific. I have created a dictionary containing pandas stats. ``` def summary_stats(s):

[issue24313] json fails to serialise numpy.int64

2016-01-04 Thread Thomas Arildsen
Thomas Arildsen added the comment: Is there any possibility that json could implement special handling of NumPy types? This "lack of a feature" seems to have propagated back into Python 2.7 now in some recent update... -- ___ Python tracker

[issue24313] json fails to serialise numpy.int64

2016-01-04 Thread Thomas Arildsen
Thomas Arildsen added the comment: Thanks for the clarification. -- versions: -Python 3.6 ___ Python tracker ___

[issue24313] json fails to serialise numpy.int64

2016-01-04 Thread Nathaniel Smith
Nathaniel Smith added the comment: Nothing's changed in python 2.7. Basically: (a) no numpy ints have ever serialized in py3. (b) in py2, either np.int32 *xor* np.int64 will serialize correctly, and which one it is depends on sizeof(long) in the C compiler used to build Python. (This follows

[issue24313] json fails to serialise numpy.int64

2015-11-16 Thread Eli_B
Changes by Eli_B : -- nosy: +Eli_B ___ Python tracker ___ ___ Python-bugs-list

[issue24313] json fails to serialise numpy.int64

2015-11-16 Thread Eli_B
Eli_B added the comment: On 64-bit Windows, my 64-bit Python 2.7.9 and my 32-bit 2.7.10 Python both reproduce the failure with a similar traceback. -- ___ Python tracker

[issue24313] json fails to serialise numpy.int64

2015-11-16 Thread Amit Feller
Changes by Amit Feller : -- nosy: +Amit Feller ___ Python tracker ___ ___

[issue24313] json fails to serialise numpy.int64

2015-05-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: I don't know about __index__, but there's the ages-old discussion of allowing some kind of __json__ hook on types. Of course, none of those solutions would allow round-tripping. -- ___ Python tracker

[issue24313] json fails to serialise numpy.int64

2015-05-29 Thread R. David Murray
R. David Murray added the comment: So in python2, some were json serializable and some weren't? Yes, I'd call that a quirk :) So back to the question of whether it makes sense for json to look for __index__ to decide if something can be serialized as an int. If not, I don't think there is

[issue24313] json fails to serialise numpy.int64

2015-05-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: I wouldn't call it a bug in Numpy (a quirk perhaps?). Numpy ints are fixed-width ints, so some of them can inherit from Python int in 2.x, but not in 3.x. But not all of them do, since the bitwidth can be different: issubclass(np.int64, int) True

[issue24313] json fails to serialise numpy.int64

2015-05-29 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +njs ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24313 ___ ___ Python-bugs-list mailing list

[issue24313] json fails to serialise numpy.int64

2015-05-28 Thread Antoine Pitrou
Antoine Pitrou added the comment: It looks like json doesn't check for __index__, and I wonder if it should. I don't know. Simply, under 2.7, int64 inherits from int: np.int64.__mro__ (type 'numpy.int64', type 'numpy.signedinteger', type 'numpy.integer', type 'numpy.number', type

[issue24313] json fails to serialise numpy.int64

2015-05-28 Thread R. David Murray
R. David Murray added the comment: Ah, so this is a numpy bug? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24313 ___ ___ Python-bugs-list

[issue24313] json fails to serialise numpy.int64

2015-05-28 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Yes, it looks as a bug (or rather lack of feature) in numpy, but numpy have no chance to fix it without help from Python. The json module is not flexible enough. For now this issue can be workarounded only from user side, with special default handler.

[issue24313] json fails to serialise numpy.int64

2015-05-28 Thread R. David Murray
R. David Murray added the comment: All python3 ints are what used to be long ints in python2, so the code that recognized short ints no longer exists. Do the numpy types implement __index__? It looks like json doesn't check for __index__, and I wonder if it should. -- nosy: