Combining Pyrex and the Pytte Runtime (Work In Progress)
Fredrik Lundh | October 2006 | Originally posted to online.effbot.org
Some “screen captures” from a few sessions working on a Pyrex/Pytte mashup.
Yet another silly experiment
> more hello1.pyx # # Hello world! # print "Hello world!" > python make.py hello1.pyx running pyrex on hello1.pyx fixing up hello1.c > cl -MD -O1 -Ipytte hello1.c pytte.c Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86 Copyright (C) Microsoft Corp 1984-1998. All rights reserved. hello1.c pytte.c Generating Code... Microsoft (R) Incremental Linker Version 6.00.8168 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. /out:hello1.exe hello1.obj pytte.obj > hello1 Hello world! > upx hello1.exe Ultimate Packer for eXecutables Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 UPX 1.25w Markus F.X.J. Oberhumer & Laszlo Molnar Jun 29th 2004 File size Ratio Format Name -------------------- ------ ----------- ----------- 16384 -> 3584 21.88% win32/pe hello1.exe Packed 1 file. > dir hello1.exe 2006-10-23 15:58 3 584 hello1.exe 1 File(s) 3 584 bytes > hello1 Hello world!
Progress
> more hello2.pyx hello = "Hello" world = "world" print hello, world + "!" > python make.py hello2 hello2.pyx ... > hello2 Hello world!
Almost There
> more hello3.pyx def hello(): print "Hello world!" hello() > python make.py hello3 hello3.pyx ... > hello3 Hello world! > more hello4.pyx data = { "H": ["Hello"], "W": ["world" + "!"], } data = data["H"][0], data["W"][0] print data[0], data[1] > python make.py hello4 hello4.pyx ... > hello4 Hello world! > dir *.exe 2006-10-24 22:30 4 608 hello3.exe 2006-10-24 23:02 5 120 hello4.exe > dumpbin /dependents hello4.exe Microsoft (R) COFF/PE Dumper Version 7.10.3077 Copyright (C) Microsoft Corporation. All rights reserved. Dump of file hello4.exe File Type: EXECUTABLE IMAGE Image has the following dependencies: KERNEL32.DLL MSVCR71.dll ...
Closer and closer
$ more hello5.pyx def say(hello, world): print hello, world say("Hello", "world!") $ gcc -O1 -o hello5 hello5.c pytte.c $ strip hello5 $ ./hello5 Hello world! $ ls -l hello5 -rwxrwxr-x 1 fredrik fredrik 9392 Oct 25 20:27 hello5