[ python-Feature Requests-846568 ] All numbers are bitarrays too

SourceForge.net noreply at sourceforge.net
Thu Jan 1 01:22:37 EST 2004


Feature Requests item #846568, was opened at 2003-11-21 08:18
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=846568&group_id=5470

Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Alexander Rødseth (alexanro)
Assigned to: Nobody/Anonymous (nobody)
Summary: All numbers are bitarrays too

Initial Comment:
It would be nice if all numbers could be used as arrays
of bits as well.

Example:

>>> i = 10
>>> i[0] = 1
>>> print i
11
>>> print list(i)
[1, 1, 0, 1]
>>> "".join(map(lambda b:str(b), l))
'1101'
>>> for bit in i: print bit
1
1
0
1


----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2004-01-01 01:22

Message:
Logged In: YES 
user_id=80475

Allowing assignments like i[o]=1 can only work for mutable
objects.   Since int is immutable, your idea would need to
be implemented as a separate extension class.

I recommend writing it first in pure python and posting it
as a cookbook recipe.  After it matures (possibly growing
other bit twiddling methods such as countbits) and has a fan
club (with some real world applications), it might warrant
coding in C.

>From my experience with the setmodule, I can say that this
is not a trivial understanding, so you really have to be
sure you've worked out the API and that it meets real needs.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=846568&group_id=5470



More information about the Python-bugs-list mailing list