[Numpy-discussion] Good use of __dunder__ methods in numpy

Gregory Lee grlee77 at gmail.com
Thu Mar 5 17:13:30 EST 2020


On Thu, Mar 5, 2020 at 2:01 PM Abdur-Rahmaan Janhangeer <
arj.python at gmail.com> wrote:

> Ah thank you for info, yes i'm talking about normal methods.
> If i can get a link to a file that shows how dunder methods help with
> having cool coding APIs that would be great!
>
> Thanks!
>
>
> Yours,
>
> Abdur-Rahmaan Janhangeer
> pythonmembers.club <http://www.pythonmembers.club/> | github
> <https://github.com/Abdur-rahmaanJ>
> Mauritius
>
>
You may want to take a look at PEP 465 as an example, then. If I recall
correctly, the __matmul__ method described in it was added to the standard
library largely with NumPy in mind.
https://www.python.org/dev/peps/pep-0465/




>
> On Thu, Mar 5, 2020 at 10:32 PM Sebastian Berg <sebastian at sipsolutions.net>
> wrote:
>
>> Hi,
>>
>> On Thu, 2020-03-05 at 11:14 +0400, Abdur-Rahmaan Janhangeer wrote:
>> > Greetings list,
>> >
>> > I have a talk about dunder methods in Python
>> >
>> > (
>> > https://conference.mscc.mu/speaker/67604187-57c3-4be6-987c-ea4bef388ad3
>> > )
>> >
>> > and it would be nice to include Numpy in the mix. Can someone point
>> > me to one or two use cases / file link where dunder methods help
>> > numpy?
>> >
>>
>> I am not sure in what sense you are looking for. NumPy has its own set
>> of dunder methods (some of which should not be used super much
>> probably), like `__array__`, `__array_interface__`, `__array_ufunc__`,
>> `__array_function__`, `__array_finalize__`, ...
>> So we are using `__array_*__` for numpy related dunders.
>>
>> Of course we use most Python defined dunders, but I am not sure that
>> you are looking for that?
>>
>> Best,
>>
>> Sebastian
>>
>>
>> > Thanks
>> >
>> > fun info: i am a tiny numpy contributor with a one line merge.
>> > _______________________________________________
>> > NumPy-Discussion mailing list
>> > NumPy-Discussion at python.org
>> > https://mail.python.org/mailman/listinfo/numpy-discussion
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion at python.org
>> https://mail.python.org/mailman/listinfo/numpy-discussion
>>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20200305/46a99477/attachment.html>


More information about the NumPy-Discussion mailing list