-
Notifications
You must be signed in to change notification settings - Fork 98
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
Feature: Accept list for __setitem__ #156
Comments
Thanks for your suggestion. I guess this means the
|
I'd like to see it compatible to numpy's advanced indexing. Not sure if they support iterable in general or only tuple and list. |
Ah, thanks. I'm not sure how useful advanced indexing features would be for a one dimensional array. As I wish to keep bitarray low-level and simple, maybe it would make sense to create a (potentially separate) library which allows creating N-dimensional bitarrays (with all the numpy features, and relying on the existing one dimensional bitarray). |
I agree, n dimensional would be an additional beast, but just setting a list of indices for one-dimensional would help a lot. Because looping in python is slow. |
I don't want to add more functionality to the core bitarray libarray. Also Python's
So your initial example
What do you think? |
I personally love the elegance of numpy's syntax - but the decision is up to you. I'm fine with your proposal. What I wonder more is if some efficiency can be gained above a simple loop in C. My indices will be in random order (hashes for bloom filter) and this might result in many pages swaps. |
I would expect the number of indices in the Bloom filter to be rather small, not more than maybe 10. One could sort those indices first, but I'm not sure if it's worth it. For a Bloom filter, a function which checks if all of the hash indices are True should also be fast. In https://github.com/ilanschnell/bitarray/blob/master/examples/bloom.py this done by:
Having a
|
The number of hash values per item is low, but if you add thousands of items in a batch to a Bloom filter, you will have many assignents and then swapping of memory pages might become a limiting factor. But no need to provide this in For
which returns a mask for each item in the batch. Related to
|
here is what I do for 2D bitarray (.mx is 1D) using Cython and it is pretty fast... you can redo it for 1D will be much simpler .. cause you use only one slice.
|
#204 has been merged, such that the original feature request
is working now. |
Set multiple indices provided as a list, e.g.
Today only
bitarray[1:5] = True
works.The text was updated successfully, but these errors were encountered: