How fast is Python dictionary?

March 30, 2009 § Leave a comment

Based on textbook theory: O(1).

I was about to do a profile test on it, but found this discussion on the mailing list. One poster claim 0.2 seconds per 1 million keys.


How Java supposed to look like on OS X

March 30, 2009 § Leave a comment

Quaqua is open source UI java library for OS X. Subjectively, IMO, it looks better than Swing and feels native on OS X.


Quaqua project page

The button Factory

March 27, 2009 § Leave a comment

This is so useful for programmer who cannot do AWESOME design… Like me.

Even Matz love Python

March 27, 2009 § Leave a comment

Matz love Python

Matz love Python

Python: cPickle vs ConfigParser vs Shelve Performance

March 26, 2009 § 4 Comments

I need to store large number of key-values to map my Python objects. These key-values DO NOT have to be replicated across multiple servers and  the project DOES NOT require external storage systems such as RDBMS or Berkeley DB or others. The least external dependencies the better.

That leads me to cPickle vs ConfigParser vs Shelve. cPickle is obvious contender, it is fast and easy to use.

ConfigParser is an interface for writing config file, but its format is very key-value ish, so it counts.

Shelve is obvious too, because of its interface.

So I ran profiler test using hot shot and here’s the result:

Profile: Saving 100000 key-value to pickle file
700001 function calls in 2.330 CPU seconds

Profile: Extracting 100000 key-value from pickle file
4 function calls in 0.258 CPU seconds

Profile: Saving 100000 key-value in ConfigParser file
900004 function calls in 2.502 CPU seconds

Profile: Extracting 100000 key-value from ConfigParser file
300007 function calls in 1.936 CPU seconds

Profile: Saving 100000 key-value to shelve file
1300047 function calls (1300045 primitive calls) in 10.091 CPU seconds

Profile: Extracting 100000 key-value from shelve file
500027 function calls in 6.527 CPU seconds

From the results:

  • Shelve is disappointingly slow. It execute 1,300,047 calls???
  • cPickle is not bad at all. As expected, it performs really quick.
  • ConfigParser is the biggest surprise here, I was expecting it to be much slower.

Side Notes:

  • I use threading.Lock before setting the key-value to prevent resource contention (which is real life case).
  • Any improvements is greatly appreciated. Especially different data storage that I’m not aware of.
  • Code can be found here.

Wiki is 14 years old now

March 25, 2009 § Leave a comment

Ward Cunningham celebrates wikis’ birthday with his colleagues at AboutUs.

Tokyo Cabinet/Tyrant for Python Programmers

March 18, 2009 § 4 Comments

1. Tokyo Tyrant Tutorial

2. Tokyo Tyrant Documentation

3. Starting Tyrant Server as Daemon: (casket.tch is the database)

ttserver -dmn -pid /tmp/ /tmp/casket.tch

4. Best documentation on how to install Tokyo Cabinet & Tyrant:

I personally go the git route.

5. To get the ‘distributed‘ feature, use Memcache Client to connect to Tokyo Tyrant server. The default port is 1978.

6. In my opinion, Tokyo Tyrant works best as Cache/Session/find_by_id solutions.


The real reason why C++ was invented

March 16, 2009 § 1 Comment

First of all, I’m not sure if this post is for real. If so, shocking. If not, it’s a very good humor.

In short, the real reason why Bjarne Stroustrup created the language is to keep software engineer salary relatively high, C++ developers nowadays indeed have very good salary.

He also mentioned that C++ doomed Mentor Graphic big time.

Read it for yourself.

C and C++ Interpreter

March 15, 2009 § Leave a comment

I never imagine anyone would bother inventing it, but some folks at ROOT (associated with CERN) thought otherwise.

The project is called CINT. It is written in C++. It is open source under MIT license.

This is gonna be fun.


CINT page

Where Am I?

You are currently viewing the archives for March, 2009 at RAPD.


Get every new post delivered to your Inbox.