-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
IntSet should be a wrapper around a BitArray #3039
Comments
IntSet already wraps an array of bits or were you thinking it should wrap a literal BitArray? |
Yes, the idea was to use a BitArray as the internal representation of IntSet. |
I took a swing at this trying to use only the public api (not accessing the fields) of BitArray. It was pretty easy, and reduces the amount of code used. However many operations are slower. I believe this is mostly due to the fact that operations like The paths forward would be to try to speed up Iteration is slightly faster, which is surprising given that in Here is a gist with my code so far: https://gist.github.com/ggggggggg/46a7e57ccff05d3a1558 a = IntSetBitVector(rand(1:10000000,1000));
b = IntSetBitVector(rand(1:10000000,1000));
println("IntSetBitVector")
@time [a==b for j = 1:100];
@time [union(a,b) for j=1:100];
@time [for i in a end for j=1:1000];
c = IntSet(rand(1:10000000,1000));
d = IntSet(rand(1:10000000,1000));
println("IntSet")
@time [c==d for j = 1:100];
@time [union(c,d) for j=1:100];
@time [for i in c end for j=1:1000]; gives
|
I decided to go ahead and directly access Timings for
|
@ggggggggg Sorry for not getting to this sooner. It seems that in a number of places (
this skips the elements which may lay between As you said in a previous message, it would probably be nice to have operators like |
I agree that relying on BitArrayViews views would be nicer, and if that is in the medium term horizon it is probably the right choice. It is my understanding that ArrayViews do not imply BitArrayViews, but perhaps there is a plan to create BitArrayViews. However I tried to avoid the problem with skipping limits between The other piece of functionality that really belongs in
|
This has been done. |
This will, in particular, allow the primes function to construct the sequence of integers as a BitArray and then return an IntSet, which is a more desirable API.
The text was updated successfully, but these errors were encountered: