Friday, January 27, 2006

Shed Skin 0.0.6

Here goes 0.0.6.. :)

With the help of Bearophile, I optimized list comprehensions and iteration a bit further. Programs are now also compiled together with the builtins, which can greatly improve performance in some cases. For example, the Pythonchess speed test engine now becomes about 22 times faster on my computer. Please check it out, and let me know about any problems you encounter.

For 0.0.7, I am working on a 'char' type. That is, let the compiler use the C++ 'char' type whenever programs are working with strings of length one. This dramatically improves the speed of programs that use strings of length 1 and/or 'string[index]' a lot. If you'd like to try it out, keep a watch on CVS, because I will commit this change soon, and let me know about any problems.

Thanks for your interest in Shed Skin. Yep, just a few library calls are implemented atm. You can see which these are, by looking at the *_.py files in the Shed Skin directory. You can easily add to these, by adding entries to these files, and supplying C++ versions in the corresponding *_.?pp files.

What kind of program are you trying to compile? Could you perhaps send it to the Shed Skin mailing list? (see http://shedskin.sourceforge.net)

The code just loads text file (line by line) that is in certain format, and formats it for inserting into database. Text file is originally from data input program made with VB.

That text file contains info about old photos: place, description, photographer, photo number etc. It then checks if that photo.jpg files exist on disk, and does name end with p (vertical) or v (horizontal).

It's only one-time-only used script, about 300 lines with comments, and there's not much use for that code without those photos and data text file. Of course if it was code that I'd use in more cases, then there would be more sense to modify it a little and make small data text file for example. I'll see if I have more time for that someday.

C++/exe version works ok, produces the same numbers as the Python version. Result lines are in different order, but that doesn't matter, I'd like to to use Shed Skin with more important code than that.

Thanks for your friendly answers!

Btw, how difficult it would be to integrate SQLite (or wxWidgets) code to Shed Skin? So that Python version would work with pySQLite, and C++ version with C++ SQLite wrapper?

Right now, you need to provide a 'type model' of each used library function, as well as a C++ implementation. I guess, for SQLite and wxWidgets, you can call the C++ version from the C++ code.

Another possibility is to write the interface in Python (so you can use anything possible in Python), and put the cpu intensive parts in a separate program. For example, if you're writing a chess program, you can put the engine in a separate program, and communicate with it via a file.

So, is there a minimal example how to make interface in Python to that compiled C++ file? So that compiled program doesn't open separate window (like exec:ing it) but it's integrated like with SWIG or something? Does calling compiled code block the f.ex. wxPython GUI working, or can it run in separate thread (or something) and then notify wxPython GUI, or get some events / progress messages from compiled file?

sorry for the delayed response. mailing me is faster :) anyway, the compiled code becomes a binary, so you can use it like any other binary. that is, run it in the background, or start it and wait for it to finish (then you need to maintain some timer, probably, to update the UI now and then.)

I just added os.listdir, str.rstrip, str.isdigit and some similar methods to CVS. I'll release them as part of SS 0.0.8 . please let me know if there are other methods you'd like me to add/implement. I'm not going to implement everything, but methods like os.listdir are quite useful and easily mapped to C++.