Re: Automatic reloading, metaclasses, and pickle

2007-02-28 Thread andrewfelch
On Feb 27, 6:47 pm, "Ziga Seilnacht" <[EMAIL PROTECTED]> wrote: > Andrew Felch wrote: > > Thanks for checking. I think I narrowed the problem down to > > inheritance. I inherit from list or some other container first: > > > class PointList( list, AutoReloader ): > > def PrintHi1(self): > >

Re: Automatic reloading, metaclasses, and pickle

2007-02-27 Thread andrewfelch
On Feb 27, 3:47 pm, "Ziga Seilnacht" <[EMAIL PROTECTED]> wrote: > Andrew Felch wrote: > > Thanks for checking. I think I narrowed the problem down to > > inheritance. I inherit from list or some other container first: > > > class PointList( list, AutoReloader ): > > def PrintHi1(self): > >

Re: Automatic reloading, metaclasses, and pickle

2007-02-27 Thread andrewfelch
On Feb 27, 3:23 pm, "Ziga Seilnacht" <[EMAIL PROTECTED]> wrote: > Andrew Felch wrote: > > I pasted the code into mine and replaced the old. It seems not to > > work for either unpickled objects or new objects. I add methods to a > > class that inherits from AutoReloader and reload the module, but

Re: Automatic reloading, metaclasses, and pickle

2007-02-27 Thread andrewfelch
On Feb 27, 5:30 pm, "Ziga Seilnacht" <[EMAIL PROTECTED]> wrote: > Andrew Felch wrote: > > > Thanks Ziga. I use pickle protocol 2 and binary file types with the > > command: "cPickle.dump(obj, file, 2)" > > > I did your suggestion, i commented out the "__call__" function of > > MetaInstanceTracker

Re: Automatic reloading, metaclasses, and pickle

2007-02-27 Thread andrewfelch
On Feb 27, 3:50 pm, "Ziga Seilnacht" <[EMAIL PROTECTED]> wrote: > Andrew Felch wrote: > > Hello all, > > > I'm using the metaclass trick for automatic reloading of class member > > functions, found > > at:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/160164 > > > My problem is that if I

Automatic reloading, metaclasses, and pickle

2007-02-27 Thread andrewfelch
Hello all, I'm using the metaclass trick for automatic reloading of class member functions, found at: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/160164 My problem is that if I 1) pickle an object that inherits from "AutoReloader" 2) unpickle the object 3) modify one of the pickled'

Re: Best way to have a for-loop index?

2006-04-05 Thread andrewfelch
Sometimes C++ is the right tool/style for the job, but I don't need the speed or efficiency of C++. -- http://mail.python.org/mailman/listinfo/python-list

Best way to have a for-loop index?

2006-03-09 Thread andrewfelch
I write a lot of code that looks like this: for myElement, elementIndex in zip( elementList, range(len(elementList))): print "myElement ", myElement, " at index: ",elementIndex My question is, is there a better, cleaner, or easier way to get at the element in a list AND the index of a loop t

Numarray - Using Integers Efficiently for Boolean Values

2006-02-16 Thread andrewfelch
Below is the code to/from Boolean arrays and Unsigned integers. On my Pentium 4, functions such as "bitwise_and" are 32 times faster when run on 32-bit integers instead of the entire-byte-consuming-Boolean. Good luck all:-) uint32Mask = numarray.array([0x0001,0x0002,0x0004,0x0008

Re: Easy way to make Numarray Bool use 1 bit?

2006-02-07 Thread andrewfelch
Ahh, I figured it out. The key is to set up the shapes so they broadcast like an outerproduct, but using bitwise_and as the operation and the second operand as the bit filter. So we temporarily expand each bit to a byte for numarray to be able to use it for dot products. If you use a temporary Bo

Easy way to make Numarray Bool use 1 bit?

2006-02-07 Thread andrewfelch
I need to be able to store thousands of one-million-length bit arrays. The first operations use the & operator. But eventually I must perform an inner product with a one-million-length integer array (summing at all the indices of the integer operand where the boolean operand has a "1"). If I use