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

Support typed array as an input when storing sequences #113

Open
pombredanne opened this issue Jun 4, 2019 · 0 comments
Open

Support typed array as an input when storing sequences #113

pombredanne opened this issue Jun 4, 2019 · 0 comments

Comments

@pombredanne
Copy link
Collaborator

pombredanne commented Jun 4, 2019

The STORE_SEQUENCE feature introduced with #27 is great but it works only from tuples as opposed to more general sequences of integers. In particular support array.array types would be great. Arrays store integers in a much more compact way than tuples.

>>> from pympler.asizeof import asizeof as s
>>> from array import array
>>> t=tuple(xrange(15000))
>>> a=array('h', xrange(15000))
>>> s(a)
31024
>>> s(t)
480056

This is because the data structure is limited to a single type and eventually you are able to store short, long, floats in the most appropriate fixed size type.
So this request is for an enhancement to allow these two things:

  1. using array as a sequence type
  2. honor the the type of the array, e.g. store shorts/long/double exactly and not something else (such as 32 bits on Py 3 or 16 bits on Py 2 as it is now).

Note that the two could be implemented separately somehow: you could specify the integer sequence type at construction time for instance and use that for any sequence and accept various sequence types when adding "words". Or we could just add support for typed array and get the int type from the array instead too.

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

2 participants