[ python-Feature Requests-887237 ] Machine integers

SourceForge.net noreply at sourceforge.net
Thu Jan 29 15:34:31 EST 2004


Feature Requests item #887237, was opened at 2004-01-29 20:34
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=887237&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Fredrik Johansson (fredrik_j)
Assigned to: Nobody/Anonymous (nobody)
Summary: Machine integers

Initial Comment:
I think it'd be useful with a built-in module (I
propose the name 'mint' :), providing classes for
emulating machine ints. There should be support for
ints of different sizes (at least 8, 16, 32, 64),
signedness and endianness. The machine ints would react
to overflow (negative values) and bit-level operations
in the same way their C equivalents would.

One idea for a feature would be a intobj.pack() (or
str() or whatever) method that could be used instead of
the struct module's pack(). int16(12345).pack() ->
"\x30\x39". int32(-1).pack() -> "\0xff\0xff\0xff\0xff",
etc.

A related idea is that these ints could provide slicing
to extract individual sets of bits or bytes. For
example, uint32()[8:16] could return an int (uint8?)
made from the bits in the int's second byte (whether
it's the second from the left or the right might be
fuzzy, I do realize).

Applications for this would be algorithmic code
involving bit fiddling (useful for cryptographic
applications, perhaps) and, obviously, programs that
have to operate on any binary data.  It might also
resolve some issues related to the unification of longs
and ints.

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

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



More information about the Python-bugs-list mailing list