[pypy-commit] pypy default: use memcpy for numpy.array.copy(), rather than going through the constructor
alex_gaynor
noreply at buildbot.pypy.org
Mon Nov 28 12:24:15 CET 2011
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r49893:56290d9adb6d
Date: 2011-11-28 06:24 -0500
http://bitbucket.org/pypy/pypy/changeset/56290d9adb6d/
Log: use memcpy for numpy.array.copy(), rather than going through the
constructor
diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -4,7 +4,7 @@
from pypy.interpreter.typedef import TypeDef, GetSetProperty
from pypy.module.micronumpy import interp_ufuncs, interp_dtype, signature
from pypy.rlib import jit
-from pypy.rpython.lltypesystem import lltype
+from pypy.rpython.lltypesystem import lltype, rffi
from pypy.tool.sourcetools import func_with_new_name
from pypy.rlib.rstring import StringBuilder
from pypy.rlib.objectmodel import instantiate
@@ -521,7 +521,10 @@
return space.wrap(self.find_size())
def descr_copy(self, space):
- return space.call_function(space.gettypefor(BaseArray), self, self.find_dtype())
+ concrete = self.get_concrete()
+ array = NDimArray(concrete.size, concrete.shape[:], concrete.dtype, concrete.order)
+ rffi.c_memcpy(array.storage, concrete.storage, array.size * array.dtype.num_bytes)
+ return array
def descr_len(self, space):
return self.get_concrete().descr_len(space)
@@ -1239,7 +1242,7 @@
class W_FlatIterator(ViewArray):
signature = signature.BaseSignature()
-
+
@jit.unroll_safe
def __init__(self, arr):
size = 1
More information about the pypy-commit
mailing list