Two open source packages: math and 2d physics

If you read slashdot, digg or reddit, these may already be familiar…


Chipmunk is a 2d physics library written in C, designed for video games. Has some videos at the website. The creator credits Box2D for inspiration in the speed of the software. Wondering what they did that speed things up (when I was in 8th grade I remember spending lots of time playing with Interactive Physics), I looked up the Box2D user manual:

Box2D tends to allocate a large number of small objects (around 50-300 bytes). Using the system heap through malloc or new for small objects is inefficient and can cause fragmentation. Many of these small objects may have a short life span, such as contacts, but can persist for several time steps. So we need an allocator that can efficiently provide heap memory for these objects.

Box2D’s solution is to use a small block allocator (SBA). The SBA keeps a number of growable pools of varying sizes. When a request is made for memory, the SBA returns a block of memory that best fits the requested size. When a block is freed, it is returned to the pool. Both of these operations are fast and cause little heap traffic.

SAGE is mathematics software, aimed to be an alternative to Magma, Maple, Mathematica, and MATLAB, in which you use Python.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s