File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -365,14 +365,21 @@ def distance(self, other):
365365 # Case 1: `sit` is an IterationInterval with statically known
366366 # trip count. E.g. it ranges from 0 to 3; `other` performs a
367367 # constant access at 4
368- for v in (self [n ], other [n ]):
369- try :
370- # NOTE: Split the boolean to make the conditional short circuit
371- # more frequently for mild speedup
372- if bool (v < sit .symbolic_min ) or bool (v > sit .symbolic_max ):
373- return Vector (S .ImaginaryUnit )
374- except TypeError :
375- pass
368+
369+ # NOTE: To avoid evaluating expensive symbolic Lt or Gt operations,
370+ # we pre-empt such operations by checking if the values to be compared
371+ # to are symbolic, and skip this case if not.
372+ if not any (isinstance (i , sympy .core .Basic )
373+ for i in (sit .symbolic_min , sit .symbolic_max )):
374+
375+ for v in (self [n ], other [n ]):
376+ try :
377+ # NOTE: Split the boolean to make the conditional short circuit
378+ # more frequently for mild speedup
379+ if bool (v < sit .symbolic_min ) or bool (v > sit .symbolic_max ):
380+ return Vector (S .ImaginaryUnit )
381+ except TypeError :
382+ pass
376383
377384 # Case 2: `sit` is an IterationInterval over a local SubDimension
378385 # and `other` performs a constant access
You can’t perform that action at this time.
0 commit comments