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
Message from discussion performance of {} versus dict()
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
 
Donald Stufft  
View profile  
 More options Nov 14 2012, 6:02 pm
From: Donald Stufft <donald.stu...@gmail.com>
Date: Wed, 14 Nov 2012 18:00:58 -0500
Local: Wed, Nov 14 2012 6:00 pm
Subject: Re: [Python-Dev] performance of {} versus dict()

$ pypy -m timeit 'dict()'
1000000000 loops, best of 3: 0.000811 usec per loop

$ pypy -m timeit '{}'    
1000000000 loops, best of 3: 0.000809 usec per loop

$ pypy -m timeit 'def md(**kw): return kw; md()'
100000000 loops, best of 3: 0.0182 usec per loop

$ pypy -m timeit -s 'def md(**kw): return kw' 'md()'
1000000000 loops, best of 3: 0.00136 usec per loop

If the difference between dict() and {} is hurting your code why are
you still using CPython.

On Wednesday, November 14, 2012 at 5:51 PM, MRAB wrote:
> On 2012-11-14 21:40, Greg Ewing wrote:
> > Chris Angelico wrote:
> > > Perhaps an alternative question: What can be done to make the latter
> > > less unpalatable?

> > * We could introduce a new syntax such as {a = 1, b = 2}.

> > * If the compiler were allowed to recognise builtins, it could
> > turn dict(a = 1, b = 2) into {'a':1, 'b':2} automatically.

> That would be a transformation of the AST, although it assumes that
> 'dict' hasn't been rebound.

> Should there be the option of a warning if a builtin is rebound? Or the
> option of the transformation plus a warning if the builtin is rebound?
> _______________________________________________
> Python-Dev mailing list
> Python-...@python.org (mailto:Python-...@python.org)
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/donald.stufft%40gma...

_______________________________________________
Python-Dev mailing list
Python-...@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/dev-python%2Bgarchi...


 
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.