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/2006-April/064467.html below:

[Python-Dev] inheriting basic types more efficiently

[Python-Dev] inheriting basic types more efficiently [Python-Dev] inheriting basic types more efficiently"Martin v. Löwis" martin at v.loewis.de
Thu Apr 27 07:20:47 CEST 2006
Dennis Heuer wrote:
> The reason why I'd like to use the long type as the base of my bitarray
> type is that the long type is already implemented as an array and
> working efficiently with large amounts of bytes.

This is wrong; you are mixing up the "is-a" and "has-a" relationships.

While it might be useful to have long as the *representation* of a
bitarray, it's not the case that a bitarray *is* a long. A bitarray
is a sequence type and should implement all aspects of the sequence
protocol; long is a numeric type and should implement numeric
operations. While the operators for these somewhat overlap (for + and
*), the semantics of the operators never overlaps. So long and
bitarray are completely distinct types, not subtypes of each other.

IOW, you should do

class bitarray:
  def __init__(self):
    self.value = 0L
  ...

Regards,
Martin
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