I second (and third & fourth &...) this

Thanks so much for this, Jaime, it's exactly what I was looking for and
couldn't find. Maybe this can be linked to in the contribute docs as an
"orienting yourself in the codebase" page?

On Wed, Jul 20, 2016 at 11:07 AM, Joseph Fox-Rabinovitz <
jfoxrabinov...@gmail.com> wrote:

> Jaime,
>
> This is a great intro for people looking to jump into the C side of
> things. I have been trying to figure out which bits are the important
> ones from looking at the code and the docs. Your post cut out most of
> the confusion. Is there some way you would consider adding something
> like this this to the docs?
>
>     -Joe
>
>
> On Wed, Jul 20, 2016 at 8:52 AM, Jaime Fernández del Río
> <jaime.f...@gmail.com> wrote:
> > On Wed, Jul 20, 2016 at 4:28 AM, Hannah <story...@gmail.com> wrote:
> >>
> >> Hi,
> >> 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.
> >
> >
> > Hi Hannah,
> >
> > ǹp.array is written in C, and is part of the multiarray module that is
> > defined here:
> >
> >
> https://github.com/numpy/numpy/blob/maintenance/1.11.x/numpy/core/src/multiarray/multiarraymodule.c
> >
> > The "array" name is mapped here:
> >
> >
> https://github.com/numpy/numpy/blob/maintenance/1.11.x/numpy/core/src/multiarray/multiarraymodule.c#L4093
> >
> > to the function _array_fromobject defined here:
> >
> >
> https://github.com/numpy/numpy/blob/maintenance/1.11.x/numpy/core/src/multiarray/multiarraymodule.c#L1557
> >
> > 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:
> >
> >
> https://github.com/numpy/numpy/blob/maintenance/1.11.x/numpy/core/src/multiarray/ctors.c#L1848
> >
> > which in turn calls Pyarray_FromAny:
> >
> >
> https://github.com/numpy/numpy/blob/maintenance/1.11.x/numpy/core/src/multiarray/ctors.c#L1674
> >
> > You will also haveto take a look at what goes on in
> > PyArray_GetArrayParamsFromObject, which gets called by PyArray_FromAny;
> >
> >
> https://github.com/numpy/numpy/blob/maintenance/1.11.x/numpy/core/src/multiarray/ctors.c#L1428
> >
> > as well as several other places, but I think they are all (or most of
> them)
> > in ctors.c.
> >
> > You may also want to take a llok at PyArray_FromIter, which is the
> function
> > that ultimately takes care of calls to np.fromiter:
> >
> >
> https://github.com/numpy/numpy/blob/maintenance/1.11.x/numpy/core/src/multiarray/ctors.c#L3657
> >
> > It's messy, but not that bad once you get used to it: good luck!
> >
> > Jaime
> >
> >>
> >>
> >> 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.
> >>
> >> Thanks,
> >> Hannah
> >>
> >> _______________________________________________
> >> NumPy-Discussion mailing list
> >> NumPy-Discussion@scipy.org
> >> https://mail.scipy.org/mailman/listinfo/numpy-discussion
> >>
> >
> >
> >
> > --
> > (\__/)
> > ( O.o)
> > ( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus
> planes de
> > dominación mundial.
> >
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion@scipy.org
> > https://mail.scipy.org/mailman/listinfo/numpy-discussion
> >
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to