Hi,
I have the following function:
def is_caught(doc, rule):
return rule.xreplace({key: key in doc for key in rule.atoms()}) == True # I have tested it also with subs instead of xreplace
This function's input is a doc which is a set of Sympy symbols, i.e. set([x,y]) and a boolean rule, i.e. And(x,z).
The function returns True if the rule is satisfied by the doc, in the above example it returns False.
I have profiled my code and 99% of the time is taken by this function. The rules and docs aren't complicated but I have a lot of them, i.e. 10 symbols over 5000 rules.
Is there any way to speed this up?