Python eval
pretty slow. I need to evaluate a simple boolean expression using boolean operators (for example, True or False). I do this for thousands of rows of data, and eval
is a huge performance bottleneck. This is really slow .. Any alternative approaches?
I tried to create a dict
possible combinations of expressions and their expected result, but it is really ugly!
I have the following code at the moment:
eval('%s %s %s' % (True, operator, False))
source share