A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-November/083545.html below:

[Python-Dev] n.numbits: method or property?

[Python-Dev] n.numbits: method or property?Mark Dickinson dickinsm at gmail.com
Wed Nov 12 19:19:57 CET 2008
[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
More information about the Python-Dev mailing list

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