[Antoine Pitrou] > No, but Python is duck-typed and alternate integer classes could adopt such an > implementation while trying to respect the Python-level long API. Good point. That makes me feel a little uneasy about adding numbits at all. Though I guess there are other parts of Python's integer API that are inherently linked to a binary representation, namely, the bit operations and shifts. And there'd be no *requirement* for alternative integer types to implement numbits (it wouldn't be part of the Integral ABC, for example). [Aahz] > What do you call Decimal? ;-) Um. A stdlib module? I guess I should have said that I can't see Python adopting a nonbinary implementation for the 'int/long' types. It *is* fun to dream about, though: there are some definite advantages to an internal decimal representation---notably, faster str <-> int conversion. And it turns out that overall performance doesn't suffer: I've coded up a Python extension module that implements decimal integers (stored internally in base 10**9) whose performance handily beats that of the current binary int/long. Mark
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4