I am not aware of a method that would allow you to run a test on values with the current set of functions.
However, depending of how frequently you perform your calculations, you might consider doing the followings:
- Use the
cache
feature:
cache – If given, it must be a boolean value specifying to enable or
disable caching of results. If you will use the same rrule instance
multiple times, enabling caching will improve the performance
considerably.
- Remap your results onto a numpy array for optimum index resolution:
Given r
being a large set of results:
>>> r # Your result set
<dateutil.rrule.rrule object at 0x7f616d4182e8>
>>> r[1] # Example of what's inside
datetime.datetime(2015, 1, 1, 0, 0)
>>> import numpy as np # Let's load numpy
>>> a = np.array(list(r)) # We build a numpy array, should be fast
>>> np.argwhere(a == datetime.datetime(2015, 1, 1, 0, 0)) # Catch'em all!
array([[1]])
I am unsure if np.argwhere()
will be faster than iterating over the result set with a simple loop, but this is a more readable approach.