Recent Changes - Search:

Get GNU Solfege at SourceForge.net. Fast, secure and Free Open Source software downloads


PythonProgramming

Don't reinvent the wheel. Use the standard python modules if they can do the job for you.


Python performance

 d = {'a': 1}

Do this:

 if 'b' in d:

and not

 if d.has_key('b')

It is 30% faster and recommended at http://www.python.org/peps/pep-0290.html


I read somewhere that method local variables are faster than self.name variables. Have to benchmark python 2.3 and 2.4 to see.


Do always catch a specific exception. Don't do like this unless you know what you are doing:

 try:
   something
 except:
   cleanup

This might be ok:

 try:
   something
 except:
   raise OtherException(blabla)
Edit - History - Print - Recent Changes - Search
Page last modified on January 28, 2005, at 12:17 AM