Skip to content
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

ENH: allow specifying bit fields in a dtype #12888

Open
mattip opened this issue Jan 30, 2019 · 0 comments
Open

ENH: allow specifying bit fields in a dtype #12888

mattip opened this issue Jan 30, 2019 · 0 comments

Comments

@mattip
Copy link
Member

mattip commented Jan 30, 2019

ctypes allows structs to specify bit size and unions:

from ctypes import *
class myPacketHeader(Structure):
    _pack_ = 1
    _fields_ = [("seqnum", c_ubyte, 8),
                ("address", c_uint, 31),
                ("is_command", c_uint, 1),
                ("length", c_ubyte, 8)]
class myUnion(Union):
    _pack_ = 1
    _fields_ = [("header", myPacketHeader),
                ("bytes", c_uint8 * 6)]

It might be nice if we could allow this in dtypes for conversion to/from structured arrays too.

Something to think about for the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant