Thrameos / jpype

Thrameos personal sandbox for enhancements to jpype to send to originell.
Other
0 stars 1 forks source link

No numpy checklist #42

Closed Thrameos closed 4 years ago

Thrameos commented 4 years ago

Attempt to deal with two (seemingly) mutually exclusive requests.

  1. Make JPype integrate with numpy better for better speed performance.
  2. Make JPype not require numpy to operate.
Thrameos commented 4 years ago

https://docs.python.org/3/c-api/typeobj.html#buffer-structs https://docs.python.org/3/library/struct.html#module-struct

Thrameos commented 4 years ago

@marscher One big challenge on this is trying to match which rules array set slice should use. The closest equivalent I can find is

https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.astype.html

My best guess currently given the prior implementation is unsafe if sizes match otherwise no conversion as we dont appear to check the Python format codes. It only checks itemsize. This is mostly safe but does automatically turn floats to gibberish as a buggy side effect if you try to cast to int.

If I have to redo it then it needs to make some sense while not blatently replicating useless bugs. Java rules would require safe with same type (double to float) but they dont specify what to do with unsigned.
Thus i am guessing safe with same type plus automatic unsigned to signed on same size would be the most compatible to our current implementation and still not allow insane conversions (double to short)

Bool and char is also weird edge cases. The most permissive bool cases is anything that is not zero is true. That would seem like Python valid syntax, but not Java safe. Char has encoding requirements and like should not take buffer syntax at all.

Do you have any opinions on this?