[Numpy-discussion] Custom dtypes without C -- or, a standard ndarray-like type

Chris Barker chris.barker at noaa.gov
Wed Sep 24 13:08:29 EDT 2014


On Tue, Sep 23, 2014 at 4:40 AM, Eric Moore <ewm at redtetrahedron.org> wrote:

>  Improving the dtype system requires working on c code.
>

yes -- it sure does. But I think that is a bit of a Red Herring. I'm barely
competent in C, and don't like it much, but the real barrier to entry for
 me is not that it's in C, but that it's really complex and hard to hack
on, as it wasn't designed to support custom dtypes, etc. from the start.
There is a lot of ugly code in there that has been hacked in to support
various functionality over time. If there was a clean dtype-extension
system in C, then A) it wouldn't be bad C to write, and B) would be pretty
easy to make a Cython-wrapped version.

Travis gave a nice vision for the future, but in the meantime, I'm
wondering:

Could we hack in a generic "custom dtype"  dtype object into the current
system that would delegate everything to the dtype object -- in a truly
object-oriented way. I'm imagining that this custom dtype object would be a
pyObject and thus very hackable, easy to make a new subclass, etc --
essentially like making a new class in python that emulates one of the
built-in type interfaces.

This would be slow as a dog -- if inside that C loop, numpy would have to
call out to python to do anyting, maybe as simple as arithmetic, but it
would be clean, extensible system, and a good way for folks to plug in and
try out new dtypes when performance didn't matter, or as prototypes for
something that would get plugged in at the C level later once the API was
worked out.

Is this even possible without too much hacking to the current dtype system?
Would it be as simple as adding a bit to the object dtype?

-Chris

-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140924/661417ab/attachment.html>


More information about the NumPy-Discussion mailing list