You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.5 KiB

From: tismer at (Christian Tismer)
Date: Wed, 21 Apr 1999 15:30:25 GMT
Subject: Bit Arrays
References: <>
Message-ID: <>
Content-Length: 1255
X-UID: 386
Jeffrey Kunce wrote:
> Take a look at ./Demo/classes/ in the python source distribution. It may be what you want, or at least give you some ideas.
> --Jeff
Interesting. This demo has not been used very much
from 1993 on, since it has a long-life bug:
def __cmp__(self, other, *rest):
#rprt(`self`+'.__cmp__'+`(other, ) + rest`+'\n')
if type(other) != type(self):
other = apply(bitvec, (other, ) + rest)
#expensive solution... recursive binary, with slicing
length = self._len
if length == 0 or other._len == 0:
return cmp(length, other._len)
if length != other._len:
min_lenght = min(length, other._len)
^- here!
return cmp(self[:min_length], other[:min_length]) or \
cmp(self[min_length:], other[min_length:])
#the lengths are the same now...
ciao - chris
Christian Tismer :^) <mailto:tismer at>
Applied Biometrics GmbH : Have a break! Take a ride on Python's
Kaiserin-Augusta-Allee 101 : *Starship*
10553 Berlin : PGP key ->
PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF
we're tired of banana software - shipped green, ripens at home