From: tismer at appliedbiometrics.com (Christian Tismer)
Date: Wed, 21 Apr 1999 15:30:25 GMT
Subject: Bit Arrays
References: <s71d9de9.045@mail.conservation.state.mo.us>
Message-ID: <371DEF11.6D06D79D@appliedbiometrics.com>
Content-Length: 1255
X-UID: 386                                                  


Jeffrey Kunce wrote:
> 
> Take a look at  ./Demo/classes/bitvec.py 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 appliedbiometrics.com>
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaiserin-Augusta-Allee 101   :    *Starship* http://starship.python.net
10553 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     we're tired of banana software - shipped green, ripens at home




