| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
This change only buffer protocol support for complex types, `_type_` properties aren't affected.
|
@encukou, I think this should fix compatibility with NumPy (buffer protocol). We can decide later what to do with _type_ (use same code or not). |
Sorry, something went wrong.
|
I'm worried that this is a breaking change relative to Python 3.14. But, with #148676 this would be redundant. |
Sorry, something went wrong.
Documentation build overview10 files changed · ± 10 modified ± Modified |
Sorry, something went wrong.
Done.
(I think merging that pr is a bad idea.) Though, you are right, my 3 PRs - only an alternative. |
Sorry, something went wrong.
|
I merged my PR instead which changes ctypes _type_. This change would be an alternative if we decide later to leave _type_ unchanged and only change the used buffer format. |
Sorry, something went wrong.
|
@vstinner, you already closed this door by #149368. Anyway, that's a kind of direction I would like to support, instead of #148676. No multiple type codes. I only worry, that in this way you also introduce incompatibility with the NumPy. That's why reversion of my changes in 3.15 and struct (deprecation) looks better for me. Lets wait decision on a PEP. Then extend the struct module in The Right Way. Then adapt other stuff. This PR does make sense only on this kind of road. |
Sorry, something went wrong.
Converting an array.array to numpy.array just works: $ python3.15
>>> import array, numpy as np
>>> a=array.array('Zd', [0])
>>> a.typecode
'Zd'
>>> n=np.array(a)
>>> n.dtype
dtype('complex128')Converting a memoryview to numpy.array also works: $ python3.15
>>> import struct, numpy as np
>>> data = struct.pack('Zd', 1j)
>>> m = memoryview(data).cast('Zd')
>>> n=np.array(m)
>>> n.dtype
dtype('complex128')
>>> n
array([0.+1.j])
I suggest continuing this discussion at https://discuss.python.org/t/choice-of-complex-buffer-protocol-format-intentional-break-with-pep/106949. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This change only buffer protocol support for complex types, _type_ properties aren't affected.