From: Lele Gaifax Date: Wed, 9 Nov 2022 07:54:12 +0000 (+0100) Subject: Add short code path for trivial comparison case X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ee8f448bfa054a3a18ce166854a6517dbe1f0a1;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Add short code path for trivial comparison case --- diff --git a/lib/sqlalchemy/dialects/postgresql/ranges.py b/lib/sqlalchemy/dialects/postgresql/ranges.py index c35b6d89d4..5706487e4d 100644 --- a/lib/sqlalchemy/dialects/postgresql/ranges.py +++ b/lib/sqlalchemy/dialects/postgresql/ranges.py @@ -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()