Bit arrays.
rdudfield at my-deja.com
rdudfield at my-deja.com
Thu Feb 10 22:23:07 EST 2000
More information about the Python-list mailing list
Thu Feb 10 22:23:07 EST 2000
- Previous message (by thread): Bit arrays.
- Next message (by thread): Bit arrays.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello, Just wondering if there is an efficient way in python to represent arrays or lists of bits? The way that I am thinking of doing it is to make a class in python and do the following: Have set and get methods for arbitary places in the array. It would store the data in an array of ints ( not sure what size yet ). The best size would depend on how you change/read the array. The set method would be implemented in the following way: *Find which element in the array of ints that the bit is in. *Convert that int into a tupple/list/array of 1s and 0s. *Find which place in the new list of 1s, and 0s the bit which needs changing. *Change that bit. *Convert the list back into a number. Get would be similar. I know this would be quite slow if you are doing lots of changes all over the array, but I am changing large ranges of bits at a time so it should be possible to cut out lots of conversions. Anyone think of better ways to do this? It would probably be worth doing this as a module in c/c++ no? Thanks in advance for any help. Rene. Sent via Deja.com http://www.deja.com/ Before you buy.
- Previous message (by thread): Bit arrays.
- Next message (by thread): Bit arrays.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list