Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > 2to3 used in the Shootout

Reply
Thread Tools

2to3 used in the Shootout

 
 
bearophileHUGS@lycos.com
Guest
Posts: n/a
 
      12-23-2008
They have translated the Python benchmarks of the Shootout site from
Py2 to Py3 using 2to3:

http://shootout.alioth.debian.org/u3...l&lang=python3

It shows some "performance bugs" of Python3 itself (especially
regarding the binary-trees benchmark, that was unexpected by me), and
two points where 2to3 may be improved, for example after the
translation this gives error:
table=string.maketrans('ACBDGHK\nMNSRUTWVYacbdghkm nsrutwvy',
'TGVHCDM
\nKNSYAAWBRTGVHCDMKNSYAAWBR')):

Gives:
TypeError: maketrans arguments must be bytes objects

Bye,
bearophile
 
Reply With Quote
 
 
 
 
Terry Reedy
Guest
Posts: n/a
 
      12-23-2008
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> They have translated the Python benchmarks of the Shootout site from
> Py2 to Py3 using 2to3:
>
> http://shootout.alioth.debian.org/u3...l&lang=python3
>
> It shows some "performance bugs" of Python3 itself (especially
> regarding the binary-trees benchmark, that was unexpected by me), and
> two points where 2to3 may be improved, for example after the
> translation this gives error:
> table=string.maketrans('ACBDGHK\nMNSRUTWVYacbdghkm nsrutwvy',
> 'TGVHCDM
> \nKNSYAAWBRTGVHCDMKNSYAAWBR')):
>
> Gives:
> TypeError: maketrans arguments must be bytes objects


Perhaps you could file a tracker item.

 
Reply With Quote
 
 
 
 
Isaac Gouy
Guest
Posts: n/a
 
      12-23-2008
On Dec 23, 11:51¬*am, (E-Mail Removed) wrote:
> They have translated the Python benchmarks of the Shootout site from
> Py2 to Py3 using 2to3:
>
> http://shootout.alioth.debian.org/u3...est=all‚Ć©=pyt...



So please re-write those programs to remove problems created by
automatic translation and better take advantage of Python 3
functionality...


http://shootout.alioth.debian.org/u32/faq.php#play



> It shows some "performance bugs" of Python3 itself (especially
> regarding the binary-trees benchmark, that was unexpected by me), and
> two points where 2to3 may be improved, for example after the
> translation this gives error:
> ¬* ¬* ¬* ¬* ¬*table=string.maketrans('ACBDGHK\nMNSRUTWVYacbdghkm nsrutwvy',
> ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* 'TGVHCDM
> \nKNSYAAWBRTGVHCDMKNSYAAWBR')):
>
> Gives:
> TypeError: maketrans arguments must be bytes objects
>
> Bye,
> bearophile


 
Reply With Quote
 
pruebauno@latinmail.com
Guest
Posts: n/a
 
      12-29-2008
On Dec 23, 5:21¬*pm, Isaac Gouy <(E-Mail Removed)> wrote:
> On Dec 23, 11:51¬*am, (E-Mail Removed) wrote:
>
> > They have translated the Python benchmarks of the Shootout site from
> > Py2 to Py3 using 2to3:

>
> >http://shootout.alioth.debian.org/u3...est=all‚Ć©=pyt...

>
> So please re-write those programs to remove problems created by
> automatic translation and better take advantage of Python 3
> functionality...
>
> http://shootout.alioth.debian.org/u32/faq.php#play
>
> > It shows some "performance bugs" of Python3 itself (especially
> > regarding the binary-trees benchmark, that was unexpected by me), and
> > two points where 2to3 may be improved, for example after the
> > translation this gives error:
> > ¬* ¬* ¬* ¬* ¬*table=string.maketrans('ACBDGHK\nMNSRUTWVYacbdghkm nsrutwvy',
> > ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* 'TGVHCDM
> > \nKNSYAAWBRTGVHCDMKNSYAAWBR')):

>
> > Gives:
> > TypeError: maketrans arguments must be bytes objects

>
> > Bye,
> > bearophile

>
>

BTW I am not sure how to submit this or if this is actually valid to
do, but I have a faster version for the pidigits program that uses
basically the same algorithm but removes function calls and unused
terms of the formula.

<pre>
import time

def pi_digits(n, width):
out = []
wrt = out.append
aq = 1
ar = 0
at = 1
k = 0
f = 1
g = 2
i = 0
while i < n:
y = (aq*3+ar)//at
while y != ((aq*4+ar)//at):
k += 1
f += 2
g += 4
ar = aq*g+ar*f
aq = aq*k
at = at*f
y = (aq*3+ar)//at
aq = 10*aq
ar = 10*ar-10*y*at
i += 1
wrt(str(y))
if not i%width:
wrt('\t:%d\n'%i)
wrt(' '*(width-i%width))
wrt('\t:%d\n'%i)
return ''.join(out)


def main():
begin = time.time()
n = 1000
width = 70
print pi_digits(n,width)
print 'Total Time:', time.time()-begin

main()

</pre>
 
Reply With Quote
 
Isaac Gouy
Guest
Posts: n/a
 
      01-02-2009
On Dec 29 2008, 8:36¬*am, (E-Mail Removed) wrote:
> On Dec 23, 5:21¬*pm, Isaac Gouy <(E-Mail Removed)> wrote:
>
> > On Dec 23, 11:51¬*am, (E-Mail Removed) wrote:

>
> > > They have translated the Python benchmarks of theShootoutsite from
> > > Py2 to Py3 using 2to3:

>
> > >http://shootout.alioth.debian.org/u3...est=all‚Ć©=pyt...

>
> > So please re-write those programs to remove problems created by
> > automatic translation and better take advantage of Python 3
> > functionality...

>
> >http://shootout.alioth.debian.org/u32/faq.php#play

>
> > > It shows some "performance bugs" of Python3 itself (especially
> > > regarding the binary-trees benchmark, that was unexpected by me), and
> > > two points where 2to3 may be improved, for example after the
> > > translation this gives error:
> > > ¬* ¬* ¬* ¬* ¬*table=string.maketrans('ACBDGHK\nMNSRUTWVYacbdghkm nsrutwvy',
> > > ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* ¬* 'TGVHCDM
> > > \nKNSYAAWBRTGVHCDMKNSYAAWBR')):

>
> > > Gives:
> > > TypeError: maketrans arguments must be bytes objects

>
> > > Bye,
> > > bearophile

>
> BTW I am not sure how to submit this or if this is actually valid to
> do, but I have a faster version for the pidigits program that uses
> basically the same algorithm but removes function calls and unused
> terms of the formula.
>
> <pre>
> import time
>
> def pi_digits(n, width):
> ¬* ¬* out = []
> ¬* ¬* wrt = out.append
> ¬* ¬* aq = 1
> ¬* ¬* ar = 0
> ¬* ¬* at = 1
> ¬* ¬* k = 0
> ¬* ¬* f = 1
> ¬* ¬* g = 2
> ¬* ¬* i = 0
> ¬* ¬* while i < n:
> ¬* ¬* ¬* ¬* y = (aq*3+ar)//at
> ¬* ¬* ¬* ¬* while y != ((aq*4+ar)//at):
> ¬* ¬* ¬* ¬* ¬* ¬* k += 1
> ¬* ¬* ¬* ¬* ¬* ¬* f += 2
> ¬* ¬* ¬* ¬* ¬* ¬* g += 4
> ¬* ¬* ¬* ¬* ¬* ¬* ar = aq*g+ar*f
> ¬* ¬* ¬* ¬* ¬* ¬* aq = aq*k
> ¬* ¬* ¬* ¬* ¬* ¬* at = at*f
> ¬* ¬* ¬* ¬* ¬* ¬* y = (aq*3+ar)//at
> ¬* ¬* ¬* ¬* aq = 10*aq
> ¬* ¬* ¬* ¬* ar = 10*ar-10*y*at
> ¬* ¬* ¬* ¬* i += 1
> ¬* ¬* ¬* ¬* wrt(str(y))
> ¬* ¬* ¬* ¬* if not i%width:
> ¬* ¬* ¬* ¬* ¬* ¬* wrt('\t:%d\n'%i)
> ¬* ¬* wrt(' '*(width-i%width))
> ¬* ¬* wrt('\t:%d\n'%i)
> ¬* ¬* return ''.join(out)
>
> def main():
> ¬* ¬* begin = time.time()
> ¬* ¬* n = 1000
> ¬* ¬* width = 70
> ¬* ¬* print pi_digits(n,width)
> ¬* ¬* print 'Total Time:', time.time()-begin
>
> main()
>
> </pre>



http://shootout.alioth.debian.org/u32q/faq.php#play
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
2to3 Help? marco.m.petersen@gmail.com Python 14 03-05-2009 01:52 PM
[2to3] Bug converting import Helmut Jarausch Python 1 06-23-2008 09:24 PM
2to3 bug and question Helmut Jarausch Python 2 06-23-2008 08:57 PM
Re: 2to3.py download Guilherme Polo Python 0 02-12-2008 12:46 PM
2to3.py download Robin Becker Python 0 02-12-2008 12:43 PM



Advertisments