RkBlog

Hardware, programming and astronomy tutorials and reviews.

Psyco - speeding up Python

Installation and usage of Psyco module

Resurected Psyco2 works, and it does it quite well. It supports only 32-bit systems, but even so the performace boost can be significant.

To install psyco get the code from SVN:

svn co http://codespeak.net/svn/psyco/v2/dist psyco2
And build/install the module:
python setup.py build
python setup.py install
To use psyco add the following at the beginning of the script:
import psyco
psyco.full()

Tests

Here is a simple md5 brute-force attack script:
import md5
import sys

haslo = 'kogut'
hasz_hasla = md5.new(haslo).hexdigest()


def make_word(m, base_string=False):
	znaki = 'qwertyuiopasdfghjklzxcvbnm'
	for i in znaki:
		if base_string:
			string = base_string + i
		else:
			string = i
		
		if md5.new(string).hexdigest() == m:
			print 'The password is: ' + string
			sys.exit()
		elif len(string) < 5:
			make_word(m=m, base_string=string)

make_word(hasz_hasla)
I've tested execution time of this script on Python 2.6 for amd64 (Gentoo) and i686 (Archlinux). The results are on the chart below. i686 finished after about 20 seconds, amd64 did the job in 14 seconds, but i686 and psyco won with 12 seconds!.
psyco1
RkBlog

Web development, 22 July 2009,

Comment article