Group dtypes together in a 'Struct' object #330
scott-griffiths
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is possibly mostly an internal efficiency idea, rather than anything that will be part of the public interface.
Basically I want to have a
Struct
class (in practice probably_Struct
) that represents a sequence of known-length dtypes. It would thus have a known length itself, together with a list of dtypes that comprise it.There could be a few advantages to this. Let's say that we want to do:
Right now this involves parsing the string, scanning for stretchy tokens, creating five dtypes, reading them and returning their values. We don't gain much by using a list of dtypes instead:
but possibly we could more efficiently do
as the
unpack
would know the structure up-front.I suspect that most use-cases are with dtypes that could be converted into structs. A method like
unpack
could first try to create aStruct
, and if it failed revert to the current code.There are also possibilities for structs to be lazy, though perhaps not in the current API. Basically it doesn't need to parse the dtypes until they are needed - this would be super useful for the bitformat module.
So could it contain arrays as well?
Seems reasonable.
Beta Was this translation helpful? Give feedback.
All reactions