summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/util/langhelpers.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-01-03 23:22:07 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2015-01-03 23:22:07 -0500
commitb1928d72098dd68c8aba468d94407f991f30d465 (patch)
tree75538ec76ebba1d331108e5297944d3b59c3e7d7 /lib/sqlalchemy/util/langhelpers.py
parent93742b3d5c16d3f1e27ff0d10c8e65e1b54971a3 (diff)
downloadsqlalchemy-b1928d72098dd68c8aba468d94407f991f30d465.tar.gz
- use a different bitwise approach here that doesn't require iterating
through all possible set values
Diffstat (limited to 'lib/sqlalchemy/util/langhelpers.py')
-rw-r--r--lib/sqlalchemy/util/langhelpers.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py
index 7f57e501a..b708665f9 100644
--- a/lib/sqlalchemy/util/langhelpers.py
+++ b/lib/sqlalchemy/util/langhelpers.py
@@ -92,6 +92,15 @@ def _unique_symbols(used, *bases):
raise NameError("exhausted namespace for symbol base %s" % base)
+def map_bits(fn, n):
+ """Call the given function given each nonzero bit from n."""
+
+ while n:
+ b = n & (~n + 1)
+ yield fn(b)
+ n ^= b
+
+
def decorator(target):
"""A signature-matching decorator factory."""