[pypy-commit] pypy default: use newlist_hint for fetching rows

bdkearns noreply at buildbot.pypy.org
Thu Apr 4 23:11:35 CEST 2013


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r63025:47167fcc4f36
Date: 2013-04-04 17:10 -0400
http://bitbucket.org/pypy/pypy/changeset/47167fcc4f36/

Log:	use newlist_hint for fetching rows

diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -30,6 +30,11 @@
 import sys
 import weakref
 from threading import _get_ident as _thread_get_ident
+try:
+    from __pypy__ import newlist_hint
+except ImportError:
+    assert '__pypy__' not in sys.builtin_module_names
+    newlist_hint = lambda sizehint: []
 
 if sys.version_info[0] >= 3:
     StandardError = Exception
@@ -920,8 +925,8 @@
             self.__row_cast_map.append(converter)
 
     def __fetch_one_row(self):
-        row = []
         num_cols = _lib.sqlite3_data_count(self.__statement._statement)
+        row = newlist_hint(num_cols)
         for i in xrange(num_cols):
             if self.__connection._detect_types:
                 converter = self.__row_cast_map[i]


More information about the pypy-commit mailing list