Multi-threading in Python

Programming with threads is one of the more difficult tasks in programming. The Python threading and Queue modules make this significantly easier, but it still takes some deliberation to use threads in an efficient way. Read more…

Nov 30th, 2007 | Filed under Programming

Dynamic URLs in Django

I long ago switched my company’s web applications from Code Igniter to Django. The main reasons were Django’s more powerful database API and Python’s maintainability and scalability over PHP. Read more…

Nov 12th, 2007 | Filed under Tips
Tags: ,

Extending Python with Pyrex

In a previous entry, I showed how to extend Python without directly using the Python C using SWIG. SWIG parses an interface file written by the programmer and then outputs a wrapper module. A more elegant, more pythonic solution might be a parser which allows a C module to be written directly in Python. Pyrex lets you write your extension module in a Python-like syntax that compiles to C. The C module can then by compiled using distutils (or gcc, et al) to a binary Python module. Read more…

Oct 23rd, 2007 | Filed under Programming
Tags: ,

Java from a functional perspective

Not long ago a project required me to learn a little Java. As a long-time elitist functional programmer, I was not extremely excited. Due to the low quality of Java software I have used, I assumed, like many, that Java produced slow, bloated, and buggy software. Some languages just feel clunky. Read more…

Oct 15th, 2007 | Filed under Soap box
Tags: , ,

Concurrency in newLISP

Threaded applications are considered to be so difficult to implement properly that programmers are often encouraged to avoid them unless absolutely necessary. This is because of the difficulty in synchronizing data between threads. There are several techniques to accomplish this. Typical solutions involve sharing an area of memory or a pipe (a channel that maps one process’ input channel to another’s output channel) in order to pass state between the two threads. The difficulty with this solution is that trouble can arise if two threads attempt to write to that same area of shared memory at the same time. One solution to this is to use a semaphore to signal threads that it is safe to write to shared memory. Other solutions involve locking the memory with a mutex lock (mutually exclusive lock). Read more…

Sep 18th, 2007 | Filed under Programming