[Numpy-discussion] Python 3 dict support (issue #5718)
Jaime Fernández del Río
jaime.frio at gmail.com
Wed Jul 20 08:52:55 EDT 2016
On Wed, Jul 20, 2016 at 4:28 AM, Hannah <story645 at gmail.com> wrote:
> I started venturing down the rabbit hole of trying to write a patch to add
> support for numpy to convert python 3 dictionary keys
> (collections.abc.ViewMapping objects), which is open issue #5718 and am
> having trouble orienting myself. I'm unclear as to where the python entry
> point into array is (basically, what function np.array drops into and if
> this is in Python or C) and where/what language (fine with writing either)
> a patch that supports MappingViews would go. Any help getting oriented
> would be much appreciated.
ǹp.array is written in C, and is part of the multiarray module that is
The "array" name is mapped here:
to the function _array_fromobject defined here:
That functions does some checking and has a couple of fast paths for the
case where the input is already an array or a subclass, but for the general
case it relies on PyArray_CheckFromAny:
which in turn calls Pyarray_FromAny:
You will also haveto take a look at what goes on in
PyArray_GetArrayParamsFromObject, which gets called by PyArray_FromAny;
as well as several other places, but I think they are all (or most of them)
You may also want to take a llok at PyArray_FromIter, which is the function
that ultimately takes care of calls to np.fromiter:
It's messy, but not that bad once you get used to it: good luck!
> The reasoning for the patch is s that dicts are one of the most common
> Python datatypes and this specifically is because of an upstream issue of
> wanting dict support in matplotlib.
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes
de dominación mundial.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion