First release of Shed Skin, a Python-to-C++ compiler.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark Dufour

    #1

    First release of Shed Skin, a Python-to-C++ compiler.

    >First the good news: ShedSkin (SS) more or less works on Windows. After[color=blue]
    >patching gc6.5 for MinGW, building it, and testing it on WinXP with
    >some succuess, and after patching my local copy of SS, I can get the
    >test.py to compile from Python to C++, and it seems that I can get
    >almost all the unit tests in unit.py to pass.[/color]

    Thank you so much for your efforts! I will try to download your
    patches this afternoon on a roommate's Windows computer, and try to
    see if I can fix the remaining tests.
    [color=blue]
    >Moreover, and since the GC system you used only works in "recent
    >versions of Windows", it follows that this solution will not work in
    >all versions. I tested it on Win98 and both GC tests and SS's unit.py
    >tests crash; although SS can still seem to compile the tests to C++.[/color]

    Thanks!! Since adding GC support took about 10 lines of C++ code, I
    guess it won't be hard to switch to a different system.. I'll try and
    see if I can add support for a version that works with Win98..

    BTW if anyone is interested in running Shed Skin under OSX.. I got
    this comment on my blog (http://shed-skin.blogspot.com)

    (why doesn't everybody just run Gentoo? :P)
    [color=blue]
    >Wow, very cool. Congratulations !
    >
    >Here's what I had to do to get it working on the Mac (OS X 10.4):
    >
    >1. Install the garbage collector from
    >http://www.hpl.hp.com/personal/Hans_Boehm/gc/
    >
    >2. Add #include <cmath> above #include <vector> in builtin_.hpp
    >
    >3. Change makelib to: g++ -dynamiclib -o libss.dylib builtin_.cpp[/color]
    sets_.cpp >random_.cpp math_.cpp copy_.cpp -lgc -lm[color=blue]
    >
    >4. Edit ss to use the appropriate path
    >
    >5. Use python 2.4 instead of the version 2.2 or 2.3 that comes with[/color]
    OS X (in my >case, I just had to put /usr/local at the start of my
    path)[color=blue]
    >
    >6. Run ./ss test.py
    >
    >7. Compile the resulting cpp file with: g++ -L. test.cpp -lss -lgc
    >
    >8. Run ./a.out and watch in awe.[/color]


    thanks!
    mark.
  • A.B., Khalid

    #2
    Re: First release of Shed Skin, a Python-to-C++ compiler.

    Mark Dufour wrote:[color=blue]
    > Thank you so much for your efforts![/color]


    Don't mention it.
    [color=blue]
    > I will try to download your patches this afternoon on a roommate's Windows
    > computer, and try to see if I can fix the remaining tests.
    >[/color]


    Okay. An update.

    - Test (124, 'small factorization program by Rohit Krishna Kumar') now
    passes on Windows. My mistake in my patching of SS header files. The
    patch is now updated. Please download again if you have an earlier
    copy.

    - Test (122, 'neural network simulator XXX later: recursive
    customization, plus some small fixes') was not really failing, it was
    just not passing. :)

    You see the Python version calls random like so:
    self.weight = (random()-0.5)/2 # [float]

    And testing output for random generated values is not going to make the
    test pass. So if we change that line to a random value generated by
    Python in the same way like so:
    self.weight = (0.889966343658 70131-0.5) # [float]

    We have then output from Python like so:
    [[0.9748332821651 0368], [0.5057507045449 5774], [0.5004717676573 9709],
    [0.9342913306358 5856], [0.5008389838936 2214], [0.9809836498198 4132],
    [0.5033858371718 114], [0.9483863670484 9744], [0.5000251073086 8799],
    [0.5091091004172 7786], [0.5128172933740 105], [0.5001015547176 9424]]


    and from the compiled SS generated C++ files like so:
    [[0.974833], [0.505751], [0.500472], [0.934291], [0.500839],
    [0.980984], [0.503386], [0.948386], [0.500025], [0.509109], [0.512817],
    [0.500102]]

    Which is okay I guess, wouldn't you agree?

    - On to Test (85, 'ifa: mixing strings and lists of strings in the same
    list'). It is still failing. It is crashing in the compiled C++
    generated from SS. But did you know that the test in pure Python is
    crashing as well?

    """
    #test03.py
    #('ifa: mixing strings and lists of strings in the same list', '''
    def row_perm_rec():
    hoppa_row = 'impossible' # [str]
    hoppa_row = [] #[list(str)]

    a = hoppa_row # [pyobj]
    hoppa_row.exten d(a) # []
    hoppa_row.appen d('u') # []

    return hoppa_row # [pyobj]

    a = [[7]] #[list(list(int))]
    s = row_perm_rec() # [pyobj]
    puzzleboard = [['']] #[list(list(str))]
    puzzleboard[1][1] = s[1] # [str]
    #''', '''
    #check('s', ['pyobj'])
    #check('a', ['list(list(int) )'])
    #check('puzzleb oard', ['list(list(str) )'])
    #output()
    """



    Running that file produces this error in all Python versions I have.:
    Traceback (most recent call last):
    File "test03.py" , line 15, in ?
    puzzleboard[1][1] = s[1] # [str]
    IndexError: list index out of range



    - Finally Test (60, '__class__ and __name__ attributes') needs
    patience. :) In Python it outputs the following:
    __main__.evert
    evert
    <type 'instance'>
    instance
    equal str!


    In the compiled C++ generated by SS it outputs the following:
    class evert
    evert
    class evert
    evert
    equal!
    [Big nasty crash]



    So there. :)


    Regards,
    Khalid

    Comment

    Working...