<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Mar 31, 2016 at 10:14 PM, Joseph Fox-Rabinovitz <span dir="ltr"><<a href="mailto:jfoxrabinovitz@gmail.com" target="_blank">jfoxrabinovitz@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There is certainly good precedent for the approach you suggest.<br>
Shortly after Nathaniel mentioned the rewrite to me, I looked up<br>
d-pointers as a possible technique: <a href="https://wiki.qt.io/D-Pointer" rel="noreferrer" target="_blank">https://wiki.qt.io/D-Pointer</a>.<br></blockquote><div><br></div><div>Yes, the idea is similar, although somewhat simpler since we are doing C, not C++.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
If we allow arbitrary kwargs for the new functions, is that something<br>
you would want to note in the public structure? I was thinking<br>
something along the lines of adding a hook to process additional<br>
kwargs and return a void * that would then be passed to the loop.<br></blockquote><div><br></div><div>I'm not sure I understand what you mean... But I also don't think it is very relevant at this point? What I intend to do is simply to hide the guts of ufuncs, breaking everyone's code once... so that we can later change whatever we want without breaking anything else. PyUFunc_GenericFunction already takes *args and **kwargs, and the internal logic of how these get processed can be modified at will. If what you are proposing is to create a PyUFunc_FromFuncAndDataAndSignatureAndKwargProcessor API function that would provide a customized function to process extra kwargs and somehow pass them into the actual ufunc loop, that would just be an API extension, and there shouldn't be any major problem in introducing that whenever, especially once we are free to modify the internal representation of ufuncs without breaking ABI compatibility.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
To do this incrementally, perhaps opening a special development branch<br>
on the main repository is in order?<br></blockquote><div><br></div><div>Yes, something like that seems like the right thing to do indeed. I would like someone with more git foo than me to spell out the details of how we would create and eventually merge that branch.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I would love to join in the fun as time permits. Unfortunately, it is<br>
not especially permissive right about now. I will at least throw in<br>
some ideas that I have been mulling over.<br></blockquote><div><br></div><div>Please do!</div><div><br></div><div>Jaime</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
    -Joe<br>
<div><div><br>
<br>
On Thu, Mar 31, 2016 at 4:00 PM, Jaime Fernández del Río<br>
<<a href="mailto:jaime.frio@gmail.com" target="_blank">jaime.frio@gmail.com</a>> wrote:<br>
> I have started discussing with Nathaniel the implementation of the ufunc ABI<br>
> break that he proposed in a draft NEP a few months ago:<br>
><br>
> <a href="http://thread.gmane.org/gmane.comp.python.numeric.general/61270" rel="noreferrer" target="_blank">http://thread.gmane.org/gmane.comp.python.numeric.general/61270</a><br>
><br>
> His original proposal was to make the public portion of PyUFuncObject be:<br>
><br>
>     typedef struct {<br>
>         PyObject_HEAD<br>
>         int nin, nout, nargs;<br>
>     } PyUFuncObject;<br>
><br>
> Of course the idea is that internally we would use a much larger struct that<br>
> we could change at will, as long as its first few entries matched those of<br>
> PyUFuncObject. My problem with this, and I may very well be missing<br>
> something, is that in PyUFunc_Type we need to set the tp_basicsize to the<br>
> size of the extended struct, so we would end up having to expose its<br>
> contents. This is somewhat similar to what now happens with PyArrayObject:<br>
> anyone can #include "ndarraytypes.h", cast PyArrayObject* to<br>
> PyArrayObjectFields*, and access the guts of the struct without using the<br>
> supplied API inline functions. Not the end of the world, but if you want to<br>
> make something private, you might as well make it truly private.<br>
><br>
> I think it would be to have something similar to what NpyIter does::<br>
><br>
>     typedef struct {<br>
>         PyObject_HEAD<br>
>         NpyUFunc *ufunc;<br>
>     } PyUFuncObject;<br>
><br>
> where NpyUFunc would, at this level, be an opaque type of which nothing<br>
> would be known. We could have some of the NpyUFunc attributes cached on the<br>
> PyUFuncObject struct for easier access, as is done in NewNpyArrayIterObject.<br>
> This would also give us more liberty in making NpyUFunc be whatever we want<br>
> it to be, including a variable-sized memory chunk that we could use and<br>
> access at will. NpyIter is again a good example, where rather than storing<br>
> pointers to strides and dimensions arrays, these are made part of the<br>
> NpyIter memory chunk, effectively being equivalent to having variable sized<br>
> arrays as part of the struct. And I think we will probably no longer trigger<br>
> the Cython warnings about size changes either.<br>
><br>
> Any thoughts on this approach? Is there anything fundamentally wrong with<br>
> what I'm proposing here?<br>
><br>
> Also, this is probably going to end up being a rewrite of a pretty large and<br>
> complex codebase. I am not sure that working on this on my own and<br>
> eventually sending a humongous PR is the best approach. Any thoughts on how<br>
> best to handle turning this into a collaborative, incremental effort? Anyone<br>
> who would like to join in the fun?<br>
><br>
> Jaime<br>
><br>
> --<br>
> (\__/)<br>
> ( O.o)<br>
> ( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes de<br>
> dominación mundial.<br>
><br>
</div></div>> _______________________________________________<br>
> NumPy-Discussion mailing list<br>
> <a href="mailto:NumPy-Discussion@scipy.org" target="_blank">NumPy-Discussion@scipy.org</a><br>
> <a href="https://mail.scipy.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
><br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org" target="_blank">NumPy-Discussion@scipy.org</a><br>
<a href="https://mail.scipy.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div>(\__/)<br>( O.o)<br>( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes de dominación mundial.</div>
</div></div>