Sometimes it is useful to be able to see fetch all keys in a dictionary which have a common value. The LookupDict class can do this.
Other times, when a 1 to 1 mapping of keys and values, and values to keys is needed, the ReverseDict class could be used.
This recipe uses NanoThreads. http://lgt.berlios.de/
It shows how simulated concurrency, (using generators as tasks), can be transparently combined with OS Level Python threads, as and when needed.
Packing images of different sizes into one image is often required in order to efficiently use hardware accelerated texture mapping functions of 3D video cards.
This fun little recipe uses Python 2.4 decorators to force function arguments to be of a specified type. If a type mismatch occurs, a TypeError is raised.
It fun, cheap, and dirty. And probably nasty.
I use this iterator when I need to iterate over an image, working on regions or subsets of the image at a time. It returns regions from a 2D range, left to right, top to bottom.
This is a strange one. Strange, and interesting. This class creates an object which returns a logarithmic progression of numbers over a period of time. It allows the target value to change, causing the progression of values to speed up, slow down,...
This useless hack allows normal functions to be attached to a 'ThunkSpace' which causes the function to be lazily evaluated when the thunk is referenced. It is just a experiment using closures and descriptors to try and change python function call...
A queue data structure, for string data only, which looks like a File object. This class takes care of the list.append and "".join mess, which is needed for fast string concatenation.
Storing modules in a central location, which are used by remote, seperate clients has obvious benefits. This recipe describes a method by which modules can be fetched from a remote server and compiled into bytecode modules which are used by the...
I often return result sets from a database call using a list of dictionary objects. When transmitting the pickled list object over the wire, the size of the pickle greatly effects the speed of the transmission.
I wrote this small class...