[pypy-commit] pypy fast_cffi_list_init: (antocuni, cfbolz around): use space.listview_{int, float} to get the internal lists of the strategies

antocuni noreply at buildbot.pypy.org
Thu Oct 10 11:24:48 CEST 2013


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: fast_cffi_list_init
Changeset: r67276:a3f89d180a33
Date: 2013-10-10 11:24 +0200
http://bitbucket.org/pypy/pypy/changeset/a3f89d180a33/

Log:	(antocuni, cfbolz around): use space.listview_{int,float} to get the
	internal lists of the strategies

diff --git a/pypy/module/_cffi_backend/ctypeptr.py b/pypy/module/_cffi_backend/ctypeptr.py
--- a/pypy/module/_cffi_backend/ctypeptr.py
+++ b/pypy/module/_cffi_backend/ctypeptr.py
@@ -60,22 +60,15 @@
 
     def _convert_array_from_list_strategy_maybe(self, cdata, w_ob):
         from rpython.rlib.rarray import copy_list_to_raw_array
-        from pypy.objspace.std.listobject import (W_ListObject,
-                                                  IntegerListStrategy, FloatListStrategy)
-        if not isinstance(w_ob, W_ListObject):
-            return False
+        int_list = self.space.listview_int(w_ob)
+        float_list = self.space.listview_float(w_ob)
         #
-        int_stragegy = self.space.fromcache(IntegerListStrategy)
-        float_strategy = self.space.fromcache(FloatListStrategy)
-        #
-        if w_ob.strategy is int_stragegy and self.ctitem.is_long():
-            int_list = IntegerListStrategy.unerase(w_ob.lstorage)
+        if self.ctitem.is_long() and int_list is not None:
             cdata = rffi.cast(rffi.LONGP, cdata)
             copy_list_to_raw_array(int_list, cdata)
             return True
         #
-        if w_ob.strategy is float_strategy and self.ctitem.is_double():
-            float_list = FloatListStrategy.unerase(w_ob.lstorage)
+        if self.ctitem.is_double() and float_list is not None:
             cdata = rffi.cast(rffi.DOUBLEP, cdata)
             copy_list_to_raw_array(float_list, cdata)
             return True


More information about the pypy-commit mailing list