2013/6/14 Mike Beller <[email protected]>

> It seems to me one needs to modify ndarray.__new__ so it can take a named
> buffer= argument, where that argument can be an mmap object.   Currently
> the python ndarray.__new__ can accept such an argument, but the numpypy one
> does not appear to.


Correct.


> When I try to figure out the changes to interp_numarray.py to make it
> work, it goes way over my head.


Hey, you need to get used to our RPython language. At least you opened the
correct file, that's a great first step :-). In interp_numarray.py:

- the block starting with "W_NDimArray.typedef" describe the type and the
methods. There is a "__new__" entry, which describes the constructor. The
implementation is descr_new_array().

- in descr_new_array(), the variables that start with "w_" are Wrapped
objects, i.e. visible to Python (similar to PyObject* in the CPython
implementation). At the moment there is a check for
"space.is_none(w_buffer)", we'll have to remove it of course.

- The goal is to use the memory allocated for w_buffer memory instead of
allocating a new one.
So don't call W_NDimArray.from_shape(),
call W_NDimArray.from_shape_and_storage() instead, it takes the raw address
of the buffer. That's it!

Of course I skipped over all the details, so the first thing to do is to
write a unit test to be sure that everything works correctly before
building a new PyPy.

-- 
Amaury Forgeot d'Arc
_______________________________________________
pypy-dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to