]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Add short code path for trivial comparison case
authorLele Gaifax <lele@metapensiero.it>
Wed, 9 Nov 2022 07:54:12 +0000 (08:54 +0100)
committerLele Gaifax <lele@metapensiero.it>
Wed, 9 Nov 2022 07:54:12 +0000 (08:54 +0100)
lib/sqlalchemy/dialects/postgresql/ranges.py

index c35b6d89d43f1e72a7307cf77961af09ac9756d3..5706487e4d3efb887a7813554d9c5ad62973bf22 100644 (file)
@@ -166,6 +166,10 @@ class Range(Generic[_T]):
         elif value2 is None:
             return 1 if value2_is_lower_bound else -1
 
+        # Short path for trivial case
+        if bound1 == bound2 and value1 == value2:
+            return 0
+
         value1_inc = bound1 in {"[", "]"}
         value2_inc = bound2 in {"[", "]"}
         step = self._get_discrete_step()