For fast numerical calculations, I often use NumPy. Although NumPy is a great tool, it is (obviously) not a good choice for given operations, since NumPy works with arrays. Even Python built-in objects are much faster than using NumPy for jobs:
Cooking:
Set Intersection :
# NumPy timeit.timeit("np.intersect1d(a, b)", setup="from __main__ import a, b, np", number=10000) > 1.3161415259819478 # Python timeit.timeit("sa.intersection(sb)", setup="from __main__ import sa, sb", number=10000) > 0.2791759959945921
Set the difference :
# NumPy timeit.timeit("np.setdiff1d(a, b)", setup="from __main__ import a, b, np", number=10000) > 0.6135410660062917 # Python timeit.timeit("sa - sb", setup="from __main__ import sa, sb", number=10000) > 0.21169587498297915
Establish a connection :
# NumPy timeit.timeit("np.union1d(a, b)", setup="from __main__ import a, b, np", number=10000) > 0.4114252869854681 # Python timeit.timeit("sa.union(sb)", setup="from __main__ import sa, sb", number=10000) > 0.2402713909978047
Of course, this is pretty unrepresentative, because a and b contain random integers ... but I tested it several times, also with ranges. NumPy has always been something like 1.5-6x slower than Python's built-in objects.
Also, I think NumPy arrays are not very good when items need to be added or removed often.
Problem . I currently work with sets that usually contain more than 10,000 elements, sometimes even millions of elements. In addition, I add or remove items quite often.
Question: Is there any library for quick installation operations in Python? Some library that offers an API for compiled material for given operations, like NumPy, for arrays / numerical operations?