Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 30 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mark Dufour  
View profile  
 More options Jul 19 2009, 10:30 am
Newsgroups: comp.lang.python
From: Mark Dufour <mark.duf...@gmail.com>
Date: Sun, 19 Jul 2009 16:30:57 +0200
Local: Sun, Jul 19 2009 10:30 am
Subject: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
Hi all,

I have just released version 0.2 of Shed Skin, an experimental
(restricted) Python-to-C++ compiler (http://shedskin.googlecode.com).
It comes with 7 new example programs (for a total of 40 example
programs, at over 12,000 lines) and several important improvements/bug
fixes. See http://code.google.com/p/shedskin/wiki/ReleaseNotes for the
full changelog.

The new example programs consist of Disco, an elegant go player (see
http://shed-skin.blogspot.com/2009/07/disco-elegant-python-go-player....),
a larger Voronoi implementation at 800 lines, a TSP algorithm
simulating ant colonies, a nicer neural network algorithm and three
compressors (Lempel-Ziv, huffman block, and arithmetic).

Other than bug fixes for these programs, this release adds some
important optimizations. First and foremost, inlining was greatly
improved, resulting in potential speedups across the board. Second,
loops such as 'for a, b in enumerate/zip(sequence[, sequence])' should
now be dramatically faster (also inside list comprehensions), by
avoiding allocation of intermediate tuples. Finally, basic list
slicing should now be much faster.

Please try it out!
Mark Dufour.
--
"One of my most productive days was throwing away 1000 lines of code"
- Ken Thompson


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William Dode  
View profile  
 More options Jul 20 2009, 7:56 am
Newsgroups: comp.lang.python
From: William Dode <w...@flibuste.net>
Date: 20 Jul 2009 11:56:49 GMT
Local: Mon, Jul 20 2009 7:56 am
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
On 19-07-2009, Mark Dufour wrote:

> Hi all,

> I have just released version 0.2 of Shed Skin, an experimental
> (restricted) Python-to-C++ compiler (http://shedskin.googlecode.com).

I just tested it with a litle game, to find the places of horse on
a board 5x5. The result is :

c 5s
gcj 7s
java 7s
shedskin 8s
python + psyco 18s
cython avec malloc *int 18s
cython 55s avec [] python
python 303s (5m3s)

--
William Dodé - http://flibuste.net
Informaticien Indépendant


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stefan Behnel  
View profile  
 More options Jul 20 2009, 9:22 am
Newsgroups: comp.lang.python
From: Stefan Behnel <stefan...@behnel.de>
Date: Mon, 20 Jul 2009 15:22:02 +0200
Local: Mon, Jul 20 2009 9:22 am
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler

William Dode wrote:
> On 19-07-2009, Mark Dufour wrote:
>> I have just released version 0.2 of Shed Skin, an experimental
>> (restricted) Python-to-C++ compiler (http://shedskin.googlecode.com).

> I just tested it with a litle game, to find the places of horse on
> a board 5x5. The result is :

> [...]
> shedskin 8s
> python + psyco 18s
> cython avec malloc *int 18s
> cython 55s avec [] python
> python 303s (5m3s)

Note that both Psyco and Cython make a lot less assumptions about Python
code than Shed Skin does. Psyco has the advantage of just needing to jump
in when it finds out that it can help, so it's the most broadly compatible
of the three. But Cython also supports quite a large corpus of dynamic
Python code by now. Shed Skin has a lot of restrictions, many of which are
by design. It's not intended to compile dynamic code, and I think that's a
good thing, because that's what makes it fast for the code that it
supports. Getting the same speed in Cython requires a bit more explicit
typing, simply because Cython does not assume these restrictions.

I think that all three have their raison d'ętre, and it currently looks
like all three are there to stay and to keep growing better. And I'm also
happy to read that some optimisations jump from one to the other. ;)

Stefan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bearophile  
View profile  
 More options Jul 20 2009, 12:26 pm
Newsgroups: comp.lang.python
From: Bearophile <bearophileH...@lycos.com>
Date: Mon, 20 Jul 2009 09:26:08 -0700 (PDT)
Local: Mon, Jul 20 2009 12:26 pm
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
William Dode':

> I just tested it with a litle game, to find the places of horse on
> a board 5x5. The result is :

> c 5s
> gcj 7s
> java 7s
> shedskin 8s
> python + psyco 18s
> cython avec malloc *int 18s
> cython 55s avec [] python
> python 303s (5m3s)

Nice timings, can you please show me the Python, Java and C code
versions? I may do more tests.
The purpose of all those "example programs" in ShedSkin is to find
bugs and to find details to speedup.

Bye,
bearophile


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
s...@pobox.com  
View profile  
 More options Jul 20 2009, 2:26 pm
Newsgroups: comp.lang.python
From: s...@pobox.com
Date: Mon, 20 Jul 2009 13:26:56 -0500
Local: Mon, Jul 20 2009 2:26 pm
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler

    William> c 5s
    William> gcj 7s
    William> java 7s
    William> shedskin 8s
    William> python + psyco 18s
    William> cython avec malloc *int 18s
    William> cython 55s avec [] python
    William> python 303s (5m3s)

I read just enough French to know that "avec" means "with", but I don't
understand the difference between "avec malloc *int" and "avec []".  Can you
explain please?

Thx,

--
Skip Montanaro - s...@pobox.com - http://www.smontanaro.net/
    That's more than a dress. That's an Audrey Hepburn movie. -- Jerry Maguire


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bearophile  
View profile  
 More options Jul 20 2009, 2:51 pm
Newsgroups: comp.lang.python
From: Bearophile <bearophileH...@lycos.com>
Date: Mon, 20 Jul 2009 11:51:18 -0700 (PDT)
Local: Mon, Jul 20 2009 2:51 pm
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
Skip Montanaro:

> I read just enough French to know that "avec" means "with", but I don't
> understand the difference between "avec malloc *int" and "avec []".  Can you
> explain please?

Maybe it's the time difference between using a Python list from Cython
and using a C "array" allocated with a malloc from Cython.

Bye,
bearophile


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
srepmub  
View profile  
 More options Jul 20 2009, 3:20 pm
Newsgroups: comp.lang.python
From: srepmub <mark.duf...@gmail.com>
Date: Mon, 20 Jul 2009 12:20:55 -0700 (PDT)
Local: Mon, Jul 20 2009 3:20 pm
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler

> Nice timings, can you please show me the Python, Java and C code
> versions? I may do more tests.

also, which shedskin options did you use? did you use -bw, to disable
bounds and wrap-around checking? this can make quite a difference for
code that does a lot of indexing. if the code uses random numbers,
then -r can also make a big difference, to use C rand(), instead of
Python compatible random numbers.

and which C++ compiler flags did you use? the default -O2, or
something like -O3 -fomit-frame-pointer -msse2..?

thanks,
mark.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William Dode  
View profile  
 More options Jul 21 2009, 4:19 am
Newsgroups: comp.lang.python
From: William Dode <w...@flibuste.net>
Date: 21 Jul 2009 08:19:29 GMT
Local: Tues, Jul 21 2009 4:19 am
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler

On 20-07-2009, srepmub wrote:

>> Nice timings, can you please show me the Python, Java and C code
>> versions? I may do more tests.

Of course, the codes are here :

http://hg.flibuste.net/libre/games/cheval

Like you'll see, i tried to use exactly the same code for each langage.

> also, which shedskin options did you use? did you use -bw, to disable
> bounds and wrap-around checking? this can make quite a difference for
> code that does a lot of indexing. if the code uses random numbers,
> then -r can also make a big difference, to use C rand(), instead of
> Python compatible random numbers.

> and which C++ compiler flags did you use? the default -O2, or
> something like -O3 -fomit-frame-pointer -msse2..?

I used the default, shedksin cheval.py; make
shedskin 0.2

With -bw and -O3 -fomit-frame-pointer -msse2 i have 5.5s (instead of 8)

Let me know if you find better.

--
William Dodé - http://flibuste.net
Informaticien Indépendant


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William Dode  
View profile  
 More options Jul 21 2009, 4:20 am
Newsgroups: comp.lang.python
From: William Dode <w...@flibuste.net>
Date: 21 Jul 2009 08:20:29 GMT
Local: Tues, Jul 21 2009 4:20 am
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler

On 20-07-2009, Bearophile wrote:
> Skip Montanaro:
>> I read just enough French to know that "avec" means "with", but I don't
>> understand the difference between "avec malloc *int" and "avec []".  Can you
>> explain please?

> Maybe it's the time difference between using a Python list from Cython
> and using a C "array" allocated with a malloc from Cython.

yes, it's this

--
William Dodé - http://flibuste.net
Informaticien Indépendant


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
srepmub  
View profile  
 More options Jul 21 2009, 8:25 am
Newsgroups: comp.lang.python
From: srepmub <mark.duf...@gmail.com>
Date: Tue, 21 Jul 2009 05:25:01 -0700 (PDT)
Local: Tues, Jul 21 2009 8:25 am
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler

> With -bw and -O3 -fomit-frame-pointer -msse2 i have 5.5s (instead of 8)

> Let me know if you find better.

thanks. now I'm wondering how fast does the C version become with
these flags..? :-)

mark.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nick Craig-Wood  
View profile  
 More options Jul 21 2009, 8:29 am
Newsgroups: comp.lang.python
From: Nick Craig-Wood <n...@craig-wood.com>
Date: Tue, 21 Jul 2009 07:29:58 -0500
Local: Tues, Jul 21 2009 8:29 am
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler

Mark Dufour <mark.duf...@gmail.com> wrote:
>  I have just released version 0.2 of Shed Skin, an experimental
>  (restricted) Python-to-C++ compiler (http://shedskin.googlecode.com).
>  It comes with 7 new example programs (for a total of 40 example
>  programs, at over 12,000 lines) and several important improvements/bug
>  fixes. See http://code.google.com/p/shedskin/wiki/ReleaseNotes for the
>  full changelog.

Cool!

I tried it on a program I wrote to solve a puzzle (Rush Hour).
(Actually it solves the meta-puzzle - trying to make the hardest
possible Rush Hour puzzle.)

After a bit of twiddling (remove psyco and profiling) I got it to
start compiling, but unfortunately it compiled for about an hour (in
iterative type analysis..) used up 600 MB of RAM printing an '*' every
10 minutes or so then gave an error message and gave up.

Unfortunately I shut the window by accident, but the error message was
something about not being able to resolve types I think with a list of
20 or so unresolved types.

Can you give a hint as to how I debug this?  I presume my program has
some instances of non static types which is causing the problem, but
it is going to be a very long debugging session if it takes me an hour
each cycle ;-)

The program is about 700 lines of python (excluding comments).

Thanks

Nick
--
Nick Craig-Wood <n...@craig-wood.com> -- http://www.craig-wood.com/nick


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William Dode  
View profile  
 More options Jul 21 2009, 8:44 am
Newsgroups: comp.lang.python
From: William Dode <w...@flibuste.net>
Date: 21 Jul 2009 12:44:30 GMT
Local: Tues, Jul 21 2009 8:44 am
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler

On 21-07-2009, srepmub wrote:

>> With -bw and -O3 -fomit-frame-pointer -msse2 i have 5.5s (instead of 8)

>> Let me know if you find better.

> thanks. now I'm wondering how fast does the C version become with
> these flags..? :-)

I don't see any difference...

--
William Dodé - http://flibuste.net
Informaticien Indépendant


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bearophile  
View profile  
 More options Jul 21 2009, 10:46 am
Newsgroups: comp.lang.python
From: Bearophile <bearophileH...@lycos.com>
Date: Tue, 21 Jul 2009 07:46:26 -0700 (PDT)
Local: Tues, Jul 21 2009 10:46 am
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
Nick Craig-Wood:

> Can you give a hint as to how I debug this?  I presume my program has
> some instances of non static types which is causing the problem, but
> it is going to be a very long debugging session if it takes me an hour
> each cycle ;-)

> The program is about 700 lines of python (excluding comments).

You can show us the Python (SSPython) code, and we can try to find the
problem. Sometimes there's no simple ways to solve such problems.

Generally for not very large progrograms if SS doesn't compile in
about a minute or so then it's gone in infinite loop (there's a
compilation flag that avoids some infinite loops, try it).

Bye,
bearophile


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bearophile  
View profile  
 More options Jul 21 2009, 11:08 am
Newsgroups: comp.lang.python
From: Bearophile <bearophileH...@lycos.com>
Date: Tue, 21 Jul 2009 08:08:37 -0700 (PDT)
Local: Tues, Jul 21 2009 11:08 am
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
William Dode':

> http://hg.flibuste.net/libre/games/cheval
> Like you'll see, i tried to use exactly the same code for each langage.

It's a cute solver.

Few more versions of mine:

#1, a Psyco version of mine:
http://codepad.org/9m5rf7kX

#2, unrolled Psyco version:
http://codepad.org/gKFLu34M

#3, a quick D (D1) version:
http://codepad.org/Tk9FL7Xk

Timings (no printing), seconds, best of 3:
#1: 4.79
#2: 3.67
#3: 1.10
Your Psyco version: 13.37
Your C version, compiled with GCC 4.3.2, -s -O3 -fomit-frame-pointer:
3.79

I have timed the whole running time of the programs, with an external
timer, so my timings include the start of the PythonVM and the final
cleanup of the GC.

Please, feel free to time my code again, so we can compare with your
other timings (Java, etc) better.

I have used Psyco 1.6 final and Python 2.6.2 on a Core2 CPU at 2 GHz.

To compile the D1 code you can use the free DMD compiler for D1, I
have used version 1.042, www.digitalmars.com/d/download.html ).

In such benchmarks it's often better to start from the fastest low
level code (written in an imperative language as C/D/C++, or a version
in a functional language like Clean or OCaML) and then use it to
create higher level versions (in Python, etc). This offers you a
baseline timing, and usually the small differences of the higher level
code compared to the original C/Clean code don't invalidate the test.

I have changed only small things in the program, as you can see the
Psyco program #2 is faster than your C code :-) If you learn how to
use it well, Psyco1.6 can often lead to very good performance. But lot
of people don't know how to use Psyco well (I too am ignorant: I don't
know how to profile Python programs yet).

Bye,
bearophile


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Terry Reedy  
View profile  
 More options Jul 21 2009, 2:26 pm
Newsgroups: comp.lang.python
From: Terry Reedy <tjre...@udel.edu>
Date: Tue, 21 Jul 2009 14:26:39 -0400
Local: Tues, Jul 21 2009 2:26 pm
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler

Split it into pieces and compile each separately.
Recurse.

tjr


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
greg  
View profile  
 More options Jul 21 2009, 8:35 pm
Newsgroups: comp.lang.python
From: greg <g...@cosc.canterbury.ac.nz>
Date: Wed, 22 Jul 2009 12:35:18 +1200
Local: Tues, Jul 21 2009 8:35 pm
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler

William Dode wrote:
> I just tested it with a litle game, to find the places of horse on
> a board 5x5. The result is :

> cython avec malloc *int 18s

Posting benchmark times for Pyrex or Cython is pretty
meaningless without showing the exact code that was
used, since times can vary enormously depending on
how much you C-ify things.

--
Greg


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bearophile  
View profile  
 More options Jul 22 2009, 2:48 am
Newsgroups: comp.lang.python
From: Bearophile <bearophileH...@lycos.com>
Date: Tue, 21 Jul 2009 23:48:55 -0700 (PDT)
Local: Wed, Jul 22 2009 2:48 am
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
greg:

> Posting benchmark times for Pyrex or Cython is pretty
> meaningless without showing the exact code that was
> used, since times can vary enormously depending on
> how much you C-ify things.

Was this link, shown by William, not enough?
http://hg.flibuste.net/libre/games/cheval/file/46797c3a5136/chevalx.p...

Bye,
bearophile


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William Dode  
View profile  
 More options Jul 22 2009, 7:38 am
Newsgroups: comp.lang.python
From: William Dode <w...@flibuste.net>
Date: 22 Jul 2009 11:38:08 GMT
Local: Wed, Jul 22 2009 7:38 am
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
I updated the script (python, c and java) with your unrolled version
+ somes litle thinks.

I also tried with python3.1, unladen Q2, ironpython1.1.1

Unfortunately it doesn't work more with shedskin, i'll see on the
shedskin group...

c 1.85s
gcj 2.15s
java 2.8s
python2.5 + psyco 3.1s
unladen-2009Q2 145s (2m45)
python2.5 254s (4m14s)
python3.1 300s (5m)
ironpython1.1.1 680s (11m20)

--
William Dodé - http://flibuste.net
Informaticien Indépendant


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
srepmub  
View profile  
 More options Jul 22 2009, 8:55 am
Newsgroups: comp.lang.python
From: srepmub <mark.duf...@gmail.com>
Date: Wed, 22 Jul 2009 05:55:57 -0700 (PDT)
Local: Wed, Jul 22 2009 8:55 am
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler

please send any program that doesn't work with shedskin (it still is
experimental after all) to me, or create an issue at
shedskin.googlecode.com, and I will have a look at the problem.

thanks,
mark.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William Dode  
View profile  
 More options Jul 22 2009, 8:59 am
Newsgroups: comp.lang.python
From: William Dode <w...@flibuste.net>
Date: 22 Jul 2009 12:59:37 GMT
Local: Wed, Jul 22 2009 8:59 am
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler

On 22-07-2009, srepmub wrote:

> please send any program that doesn't work with shedskin (it still is
> experimental after all) to me, or create an issue at
> shedskin.googlecode.com, and I will have a look at the problem.

I did it, on the discussion group
http://groups.google.com/group/shedskin-discuss/browse_thread/thread/...

--
William Dodé - http://flibuste.net
Informaticien Indépendant


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
George Sakkis  
View profile  
 More options Jul 22 2009, 10:55 am
Newsgroups: comp.lang.python
From: George Sakkis <george.sak...@gmail.com>
Date: Wed, 22 Jul 2009 07:55:38 -0700 (PDT)
Local: Wed, Jul 22 2009 10:55 am
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
On Jul 22, 7:38 am, William Dode <w...@flibuste.net> wrote:

Cool; it would be interesting to see the numbers for Jython and Boo as
well if it's not too much effort.

George


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William Dode  
View profile  
 More options Jul 22 2009, 12:45 pm
Newsgroups: comp.lang.python
From: William Dode <w...@flibuste.net>
Date: 22 Jul 2009 16:45:19 GMT
Local: Wed, Jul 22 2009 12:45 pm
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
On 22-07-2009, George Sakkis wrote:

I just tried with jython, but oddly it's faster without array.
Thanks to Mark, i could compile to shedskin again.
And add somes little improvements...

c 1.65s
gcj 1.9s
java 2.4s
python2.5 + psyco 2.9s
shedskin 3.4s
unladen-2009Q2 125s (2m05)
Jython 2.2.1 on java1.6.0_12 176s (without array, like shedskin)
Jython 2.2.1 on java1.6.0_12 334s (with array)
python2.5 215s (3m35s)
python3.1 246s (4m06s)
ironpython1.1.1 512 (8m32s)

--
William Dodé - http://flibuste.net
Informaticien Indépendant


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William Dode  
View profile  
 More options Jul 22 2009, 1:55 pm
Newsgroups: comp.lang.python
From: William Dode <w...@flibuste.net>
Date: 22 Jul 2009 17:55:34 GMT
Local: Wed, Jul 22 2009 1:55 pm
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
On 22-07-2009, William Dode wrote:

> c 1.65s
> gcj 1.9s
> java 2.4s
> python2.5 + psyco 2.9s
> shedskin 3.4s

with -bw i have 2.6s

> unladen-2009Q2 125s (2m05)
> Jython 2.2.1 on java1.6.0_12 176s (without array, like shedskin)
> Jython 2.2.1 on java1.6.0_12 334s (with array)
> python2.5 215s (3m35s)
> python3.1 246s (4m06s)
> ironpython1.1.1 512 (8m32s)

somebody can test with ironpython on windows ?

Anyway, it's very impressive. I wonder if unladen will be so close in
the futur.

--
William Dodé - http://flibuste.net
Informaticien Indépendant


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
George Sakkis  
View profile  
 More options Jul 22 2009, 4:27 pm
Newsgroups: comp.lang.python
From: George Sakkis <george.sak...@gmail.com>
Date: Wed, 22 Jul 2009 13:27:13 -0700 (PDT)
Local: Wed, Jul 22 2009 4:27 pm
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
On Jul 22, 12:45 pm, William Dode <w...@flibuste.net> wrote:

FYI Jython 2.5 was released last month, you may want to try this
instead of 2.2.

George


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kurt Smith  
View profile  
 More options Jul 22 2009, 9:25 pm
Newsgroups: comp.lang.python
From: Kurt Smith <kwmsm...@gmail.com>
Date: Wed, 22 Jul 2009 21:25:17 -0400
Local: Wed, Jul 22 2009 9:25 pm
Subject: Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler

On Wed, Jul 22, 2009 at 2:48 AM, Bearophile<bearophileH...@lycos.com> wrote:
> greg:
>> Posting benchmark times for Pyrex or Cython is pretty
>> meaningless without showing the exact code that was
>> used, since times can vary enormously depending on
>> how much you C-ify things.

> Was this link, shown by William, not enough?
> http://hg.flibuste.net/libre/games/cheval/file/46797c3a5136/chevalx.p...

I took a stab at converting the recent psyco-optimized code to cython,
and got a speedup.

gcj    4.3.3    1.39s
gcc    4.3.3    1.55s
cython 11.2     1.91s
psyco           1.94s
javac  1.5.0_19 2.00s
python 2.5.4    168.37s

It was just a matter of cdef-ing all the arrays & integers --
bearophile already did the hard work :-)

Here's the cython code; all the others are from the repo.

#################################################
DEF NMOVES = 8
DEF SIDE = 5
DEF SQR_SIDE = SIDE * SIDE

cdef int circuit[SQR_SIDE]
cdef int nsolutions = 0

cdef int movex[NMOVES]
cdef int movey[NMOVES]
py_movex = [-1,-2,-2,-1,+1,+2,+2,+1]
py_movey = [-2,-1,+1,+2,+2,+1,-1,-2]
for i in range(NMOVES):
   movex[i] = py_movex[i]
   movey[i] = py_movey[i]
shift = [x * SIDE + y for x,y in zip(py_movex, py_movey)]
cdef int shift_0 = shift[0]
cdef int shift_1 = shift[1]
cdef int shift_2 = shift[2]
cdef int shift_3 = shift[3]
cdef int shift_4 = shift[4]
cdef int shift_5 = shift[5]
cdef int shift_6 = shift[6]
cdef int shift_7 = shift[7]

def showCircuit():
   print
   for x in xrange(SIDE):
       x_SIDE = x * SIDE
       for y in xrange(SIDE):
           if SQR_SIDE < 100:
               print "%02d " % circuit[x_SIDE + y],
           else:
               print "%03d " % circuit[x_SIDE + y],
       print

cdef void solve(int nb, int x, int y,
       int SIDE=SIDE, int SQR_SIDE=SQR_SIDE, int *circuit=circuit,
       int shift_0=shift_0,
       int shift_1=shift_1,
       int shift_2=shift_2,
       int shift_3=shift_3,
       int shift_4=shift_4,
       int shift_5=shift_5,
       int shift_6=shift_6,
       int shift_7=shift_7,
       ):
   global nsolutions

   cdef int newx, newy
   cdef int pos = x * SIDE + y
   circuit[pos] = nb
   if nb == SQR_SIDE:
       #showCircuit()
       nsolutions += 1
       circuit[pos] = 0
       return

   newx = x + -1
   if newx >= 0 and newx < SIDE:
       newy = y + -2
       if newy >= 0 and newy < SIDE and not circuit[pos + shift_0]:
           solve(nb+1, newx, newy)

   newx = x + -2
   if newx >= 0 and newx < SIDE:
       newy = y + -1
       if newy >= 0 and newy < SIDE and not circuit[pos + shift_1]:
           solve(nb+1, newx, newy)

   newx = x + -2
   if newx >= 0 and newx < SIDE:
       newy = y + 1
       if newy >= 0 and newy < SIDE and not circuit[pos + shift_2]:
           solve(nb+1, newx, newy)

   newx = x + -1
   if newx >= 0 and newx < SIDE:
       newy = y + 2
       if newy >= 0 and newy < SIDE and not circuit[pos + shift_3]:
           solve(nb+1, newx, newy)

   newx = x + 1
   if newx >= 0 and newx < SIDE:
       newy = y + 2
       if newy >= 0 and newy < SIDE and not circuit[pos + shift_4]:
           solve(nb+1, newx, newy)

   newx = x + 2
   if newx >= 0 and newx < SIDE:
       newy = y + 1
       if newy >= 0 and newy < SIDE and not circuit[pos + shift_5]:
           solve(nb+1, newx, newy)

   newx = x + 2
   if newx >= 0 and newx < SIDE:
       newy = y + -1
       if newy >= 0 and newy < SIDE and not circuit[pos + shift_6]:
           solve(nb+1, newx, newy)

   newx = x + 1
   if newx >= 0 and newx < SIDE:
       newy = y + -2
       if newy >= 0 and newy < SIDE and not circuit[pos + shift_7]:
           solve(nb+1, newx, newy)

   circuit[pos] = 0

def main():
   print "Search for side=%d" % SIDE
   cdef int x,y
   for x in range(SIDE):
       for y in range(SIDE):
           solve(1, x, y);
   print "\n%dx%d case, %d solutions." % (SIDE, SIDE, nsolutions)

def run():
   import time
   s=time.time()
   main()
   print time.time()-s
#################################################


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 30   Newer >
« Back to Discussions « Newer topic     Older topic »