BUG: np.dtype(ctypes.Structure) does not respect _pack_ field
See original GitHub issueclass Foo(ctypes.Structure):
_fields_ = [('one', ctypes.c_uint8), ('two', ctypes.c_uint32)]
_pack_ = 2
>>> ctypes.sizeof(Foo()) # packed to alignment 2
6
>>> np.dtype(Foo).itemsize # default alignment incorrectly used
8
Fix should be fairly straightforward by changing:
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Numpy error when converting array of ctypes types to void ...
At 1 st glance, it seems it's a ctypes bug as it doesn't respect the standard, but I wouldn't rush into claiming this...
Read more >NumPy 1.17.0 Release Notes
Shape-1 fields in dtypes won't be collapsed to scalars in a future version#. Currently, a field specified as [(name, dtype, 1)] or "1type" ......
Read more >schrodinger.application.matsci.elasticity.stress module ...
Starting in NumPy 1.9, astype method now returns an error if the string dtype to cast to is not long enough in 'safe'...
Read more >Release Notes — NumPy v1.12 Manual - GitHub Pages
np.full now returns an array of the fill-value's dtype if no dtype is given, ... #7156: BUG: Reascertain that linspace respects ndarray subclasses...
Read more >Issue 41883: ctypes pointee goes out of scope, then pointer in ...
msg377652 ‑ (view) Author: Ian M. Hoffman (NankerPhelge) Date: 2020‑09‑29 03:40
msg377657 ‑ (view) Author: Eryk Sun (eryksun) * Date: 2020‑09‑29 05:46
msg377674 ‑ (view)...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I would not like to encourage deeper use of ctypes. The code behind them has many open issues. The package defines yet-another-dsl for describing c-like interfaces. It has so many layers it will always be slow and buggy. Why not directly inherit from a new
dtypes.baseclass
that returnsNotImplemented
where needed instead?@tylerjereddy:
A neat but rather pointless trick