Re: Efficient Bit addressing in Python.

2008-10-12 Thread Hendrik van Rooyen
Ross Ridge wrote: >Unfortunately from your other posts you do seem to be working on >a single byte a time, so my technique probably won't be efficient. Its a bit more - the hardware allows for 64 lines in and 64 lines out. >You probably want just want to be using constants and bit masking. >S

Re: Efficient Bit addressing in Python.

2008-10-11 Thread Ross Ridge
Ross Ridge wrote: >I don't think you can do anything faster with standard modules, although >it might not be efficient if you're only working with a single byte. Hendrik van Rooyen <[EMAIL PROTECTED]> wrote: >Thanks I was not aware of binascii module this looks powerful. Not really. It's just u

Re: Efficient Bit addressing in Python.

2008-10-11 Thread Hendrik van Rooyen
Lie wrote: >> This of course means that there has to be another >> thread active to actually do the i/o on a periodic basis, >> gathering the outputs and writing them out, and reading >> the inputs and scattering them to the various named input >> bits > >Not necessarily. You've mentioned two way

Re: Efficient Bit addressing in Python.

2008-10-11 Thread Hendrik van Rooyen
Ross Ridge wrote: >This is the code I use to convert large bit arrays to byte strings and >back: > >import string >import binascii >import array 8<--- examples -- >I don't think you can do anything faster with standard modules, although >it might not be efficient

Re: Efficient Bit addressing in Python.

2008-10-11 Thread Hendrik van Rooyen
"Aaron \"Castironpi\" Brady" wrote: >This is tolerable. Â If you've got a better 'clear' operation than >'xor', you're welcome to it. *grin* xor is a toggle bit fuction, and I did not like the recursive call in your code. so here is a module bsed on your BitSet: (I hope my tabs survive the journe

Re: Efficient Bit addressing in Python.

2008-10-10 Thread Aaron "Castironpi" Brady
On Oct 10, 10:37 pm, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]> wrote: > On Oct 9, 5:30 pm, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > > > > > Is there a canonical way to address the bits in a structure > > like an array or string or struct? > > > Or alternatively, is there a good way

Re: Efficient Bit addressing in Python.

2008-10-10 Thread Aaron "Castironpi" Brady
On Oct 9, 5:30 pm, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > Is there a canonical way to address the bits in a structure > like an array or string or struct? > > Or alternatively, is there a good way to combine eight > ints that represent bits into one of the bytes in some > array or string

Re: Efficient Bit addressing in Python.

2008-10-10 Thread Lie
On Oct 11, 5:27 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > This of course means that there has to be another > thread active to actually do the i/o on a periodic basis, > gathering the outputs and writing them out, and reading > the inputs and scattering them to the various named input >

Re: Efficient Bit addressing in Python.

2008-10-10 Thread Lie
On Oct 11, 5:27 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > This of course means that there has to be another > thread active to actually do the i/o on a periodic basis, > gathering the outputs and writing them out, and reading > the inputs and scattering them to the various named input >

Re: Efficient Bit addressing in Python.

2008-10-10 Thread Hendrik van Rooyen
"Tino Wildenhain" wrote: > Hendrik van Rooyen wrote: > > "Tino Wildenhain" wrote: 8< > > Sure, one could for instance make a list of eight-entry lists: > > > > io = [[b0,b1,b2,b3,b4,b5,b6,b7],] > > what should that represent? Which byte order > do you have in

Re: Efficient Bit addressing in Python.

2008-10-10 Thread Hendrik van Rooyen
Mensanator wrote: >I use the gmpy module for all my bit related work and >have been very satisfied with the results. 8<--- gmpy function list --- Thanks. All of this looks good. Will check out gmpy too. - Hendrik -- http://mail.python.org/mailman/listinfo/python-

Re: Efficient Bit addressing in Python.

2008-10-10 Thread Hendrik van Rooyen
George Sakkis wrote: >I don't know of a canonical way (bit hacking is not really common in >Python) but pehaps BitPacket [1] comes close to what you're after. > >George > >[1] http://hacks-galore.org/aleix/BitPacket/ Thanks for the link - I will check it out - Hendrik -- http://mail.python.org/

Re: Efficient Bit addressing in Python.

2008-10-10 Thread Hendrik van Rooyen
Lie Ryan wrote: >You'll find that in most cases, using integer or Boolean is enough. There >are some edge cases, which requires bit addressing for speed or memory >optimizations, in python, the usual response to that kind of optimization >requirement is to move that part of the code to C. > >If,

Re: Efficient Bit addressing in Python.

2008-10-10 Thread Ross Ridge
Hendrik van Rooyen <[EMAIL PROTECTED]> wrote: >Is there a canonical way to address the bits in a structure >like an array or string or struct? > >Or alternatively, is there a good way to combine eight >ints that represent bits into one of the bytes in some >array or string or whatever? This is the

Re: Efficient Bit addressing in Python.

2008-10-10 Thread Tino Wildenhain
Hendrik van Rooyen wrote: "Tino Wildenhain" wrote: byte1 byte2? this does not look very practical to me. In the simplest form of storing your values in a text string, you could just use ord() to get the byte value and operate on it with 1<<0 1<<1 1<<3 and so on. If you want, put a module in

Re: Efficient Bit addressing in Python.

2008-10-10 Thread Hendrik van Rooyen
"Tino Wildenhain" wrote: > > byte1 byte2? this does not look very practical > to me. In the simplest form of storing > your values in a text string, you could just > use ord() to get the byte value and > operate on it with 1<<0 1<<1 1<<3 and so on. > > If you want, put a module in which defin

Re: Efficient Bit addressing in Python.

2008-10-09 Thread Mensanator
On Oct 9, 5:30 pm, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > Is there a canonical way to address the bits in a structure > like an array or string or struct? > > Or alternatively, is there a good way to combine eight > ints that represent bits into one of the bytes in some > array or string

Re: Efficient Bit addressing in Python.

2008-10-09 Thread George Sakkis
On Oct 9, 6:30 pm, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > Is there a canonical way to address the bits in a structure > like an array or string or struct? I don't know of a canonical way (bit hacking is not really common in Python) but pehaps BitPacket [1] comes close to what you're af

Re: Efficient Bit addressing in Python.

2008-10-09 Thread Lie Ryan
On Fri, 10 Oct 2008 00:30:18 +0200, Hendrik van Rooyen wrote: > Is there a canonical way to address the bits in a structure like an > array or string or struct? > > Or alternatively, is there a good way to combine eight ints that > represent bits into one of the bytes in some array or string or >

Re: Efficient Bit addressing in Python.

2008-10-09 Thread Tino Wildenhain
Hi, Hendrik van Rooyen wrote: Is there a canonical way to address the bits in a structure like an array or string or struct? Or alternatively, is there a good way to combine eight ints that represent bits into one of the bytes in some array or string or whatever? It seems to me that there is a

Efficient Bit addressing in Python.

2008-10-09 Thread Hendrik van Rooyen
Is there a canonical way to address the bits in a structure like an array or string or struct? Or alternatively, is there a good way to combine eight ints that represent bits into one of the bytes in some array or string or whatever? It seems to me that there is a dilemma here : if you can writ