Snippet: bitcount()

Christian Tismer tismer at appliedbiometrics.com
Sat Jul 17 09:49:28 EDT 1999


Michael Hudson wrote:
> 
> Christian Tismer <tismer at appliedbiometrics.com> writes:
> 
> > > Mini-proposal: len(a) for a long returns the length of the number in
> > > radix-256.
> >
> > bitcount2 is not very slow, see here:

> Still chews gobs of memory though... is there any way of converting
> longs <-> arrays? That'd do the trick, though you'd still end up
> copying, no doubt. Still, I don't think I'm being realistic to talk of
> dealing with numbers so large copying them is an issue in Python. It's
> all just for play, anyway.

No way to do that. Longs are exposed to marshal only at this
time. I guess it could be made visible as a read-only buffer
if we extend the buffer function (i.e. extend longs with
buffer methods), but is it worth it?
The single copy for marshal is very cheap, compared to hex.

if-we-had-this-trick-you-would-have-seen-it-in-the-thread - 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




More information about the Python-list mailing list