[pypy-commit] pypy default: make namedtuple fast
fijal
noreply at buildbot.pypy.org
Wed Mar 20 20:14:27 CET 2013
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch:
Changeset: r62552:8bd3b5c5365d
Date: 2013-03-20 12:14 -0700
http://bitbucket.org/pypy/pypy/changeset/8bd3b5c5365d/
Log: make namedtuple fast
diff --git a/lib-python/2/collections.py b/lib-python/2/collections.py
--- a/lib-python/2/collections.py
+++ b/lib-python/2/collections.py
@@ -12,6 +12,10 @@
import heapq as _heapq
from itertools import repeat as _repeat, chain as _chain, starmap as _starmap
from itertools import imap as _imap
+try:
+ from __pypy__ import newdict
+except ImportError:
+ newdict = lambda _ : {}
try:
from thread import get_ident as _get_ident
@@ -326,8 +330,11 @@
# Execute the template string in a temporary namespace and
# support tracing utilities by setting a value for frame.f_globals['__name__']
- namespace = dict(__name__='namedtuple_%s' % typename,
- OrderedDict=OrderedDict, _property=property, _tuple=tuple)
+ namespace = newdict('module')
+ namespace['OrderedDict'] = OrderedDict
+ namespace['_property'] = property
+ namespace['_tuple'] = tuple
+ namespace['__name__'] = 'namedtuple_%s' % typename
try:
exec template in namespace
except SyntaxError, e:
More information about the pypy-commit
mailing list