Py 3 slower than Py 2. Towers of Hanoi implementation
Udyant Wig
udyantw at gmail.com
Fri Jun 26 10:37:09 EDT 2009
On Jun 26, 7:14 pm, Stefan Behnel <stefan... at behnel.de> wrote:
> Udyant Wig wrote:
> > I implemented this ->http://www.apl.jhu.edu/~hall/lisp/Hanoi.lispin
> > both flavors of Python: 2.6.2 and 3.0.1 (CPython)
>
> > The code:
> > #!/usr/bin/env python
> > def remaining_peg (peg1, peg2):
> > return (6 - peg1 - peg2)
>
> > def hanoi (num_discs, start, end):
> > if (1 == num_discs):
> > print "Top of peg {0} to peg {1}".format(start,end) # used print()
> > for Py 3.0.1
>
> > else:
> > hanoi ((num_discs - 1), start, (remaining_peg (start, end)))
> > hanoi (1, start, end)
> > hanoi ((num_discs - 1), (remaining_peg (start, end)), end)
>
> > hanoi(20,2,3)
>
> > The times: real usr sys
> > Python 2.6.2 7.994s 3.336s 3.296s
> > Python 3.0.1 55.302s 38.024s 5.876s
>
> > What happened to Python?
>
> Have you tried Python 3.1? Have you made sure that both Python interpreters
> were build with the same compiler arguments and that none of them is a
> debug build?
>
> Stefan
Yes. Both were built with the same compiler parameters.
No. None of them is a debug build.
I'm currently getting Python 3.1
More information about the Python-list
mailing list