[pypy-svn] r7444 - pypy/trunk/src/pypy/translator
arigo at codespeak.net
arigo at codespeak.net
Fri Nov 19 15:23:14 CET 2004
Author: arigo
Date: Fri Nov 19 15:23:13 2004
New Revision: 7444
Modified:
pypy/trunk/src/pypy/translator/genc.py
Log:
We shouldn't build tuples lazily, because they can be used e.g. as keys in
dictionaries before they are ready.
Modified: pypy/trunk/src/pypy/translator/genc.py
==============================================================================
--- pypy/trunk/src/pypy/translator/genc.py (original)
+++ pypy/trunk/src/pypy/translator/genc.py Fri Nov 19 15:23:13 2004
@@ -291,14 +291,11 @@
def nameof_tuple(self, tup):
name = self.uniquename('g%dtuple' % len(tup))
- def inittuple():
- for i in range(len(tup)):
- item = self.nameof(tup[i])
- yield '\tPy_INCREF(%s);' % item
- yield '\tPyTuple_SET_ITEM(%s, %d, %s);' % (name, i, item)
self.globaldecl.append('static PyObject* %s;' % name)
- self.initcode.append('INITCHK(%s = PyTuple_New(%d))' % (name, len(tup)))
- self.latercode.append(inittuple())
+ args = [self.nameof(x) for x in tup]
+ args.insert(0, '%d' % len(tup))
+ args = ', '.join(args)
+ self.initcode.append('INITCHK(%s = PyTuple_Pack(%s))' % (name, args))
return name
def nameof_list(self, lis):
More information about the Pypy-commit
mailing list