Author: Antonio Cuni <[email protected]>
Branch: fast_cffi_list_init
Changeset: r67251:e3f5920e0686
Date: 2013-10-09 18:23 +0200
http://bitbucket.org/pypy/pypy/changeset/e3f5920e0686/

Log:    implement the fast-path also for double[] and floatstrategy

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,18 +60,26 @@
 
     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
+        from pypy.objspace.std.listobject import (W_ListObject,
+                                                  IntegerListStrategy, 
FloatListStrategy)
         if not isinstance(w_ob, W_ListObject):
             return False
         #
         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 = w_ob.strategy.unerase(w_ob.lstorage)
             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 = w_ob.strategy.unerase(w_ob.lstorage)
+            cdata = rffi.cast(rffi.DOUBLEP, cdata)
+            copy_list_to_raw_array(float_list, cdata)
+            return True
+        #
         return False
 
     def _convert_array_from_listview(self, cdata, w_ob):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to