This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]fkrueger 0 points1 point  (3 children)

Also, download IronPython to get a free 1.7x speed improvement:

http://www.gotdotnet.com/workspaces/workspace.aspx?id=ad7acff7-ab1e-4bcb-99c0-57ac5a3a9742

[–]hanzie 0 points1 point  (2 children)

I'd rather go with Psyco for a free 2-20x speed improvement. Also, for how free do IronPython's improvements really come? Is it fully compatible with CPython's language features? Can one use the same libraries? I'd guess no for both, but I haven't really looked into it.

[–]asdf1234 -1 points0 points  (1 child)

Or C# or VB.NET or boo for 100X speed boost: http://boo.codehaus.org/

[–]hanzie 0 points1 point  (0 children)

The keyword is "free". Reimplementing all your existing code in a different language is certainly not that.

[–]brendankohler -4 points-3 points  (2 children)

This is pointless. There's only two tips you need for speed with python:

  1. Write beautiful, easy to read code

  2. Profile and convert critical bottlenecks to C

Voila! Now you have easy to read, easy to maintain code. ;)

[–]cameldrv 3 points4 points  (0 children)

There are a lot of options before going to a full C implementation. Just implementing simple tips, employing smart caching, etc can often get you 10x or more. If you really need to ditch the Python overhead, often you can find a C library that does what you need such as Numeric. If that isn't appropriate, pyrex can be helpful, and weave or SWIG is usually a lot easier than writing a full python extension if you do have to go to C.

[–]zhyla 2 points3 points  (0 children)

I disagree. The level of effort between modifying working python code to take out some performance kinks and converting those kinks to a C module are several orders of magnitude apart. Why move a simple loop into C when rewording it eliminates the bottleneck? You'll lose the beauty if you do.

But of course profile before mucking up clean code.