[Numpy-discussion] Fwd: [Python-ideas] PEP pre-draft: Support for indexing with keyword arguments

Stephan Hoyer shoyer at gmail.com
Wed Jul 2 14:01:23 EDT 2014


NumPy doesn't have named axes, but perhaps it should. See, for example,
Fernando Perez's datarray prototype (https://github.com/fperez/datarray) or
my project, xray (https://github.com/xray/xray).

Syntactical support for indexing an axis by name would makes using named
axes much more readable. For example, compare:

gridValues[x=3, y=5, z=0:8] = 0

vs.

gridValues.set_items(dict(x=3, y=5, z=slice(0, 8)), 0)

This is case 2 in the draft PEP.

I am less sure about the other cases. For some of these, such as get with a
default, using a function call is a perfectly fine substitute.

Best,
Stephan




On Wed, Jul 2, 2014 at 1:49 AM, Nathaniel Smith <njs at pobox.com> wrote:

> There's some discussion on python-ideas about making it possible for
> python indexing to accept kwargs, eg
>
>    arr[1:2, foo=bar]
>
> Since numpy is a very heavy user of indexing which might benefit from
> this, I thought I should forward it here. If we have clear use cases for
> such a feature then that may strongly affect the discussion.
>
> I admit I can't actually think of any features this would enable for us
> though...
>
> -n
> ---------- Forwarded message ----------
> From: "Stefano Borini" <stefano.borini at ferrara.linux.it>
> Date: 2 Jul 2014 00:17
> Subject: [Python-ideas] PEP pre-draft: Support for indexing with keyword
> arguments
> To: "python-ideas at python.org" <python-ideas at python.org>, "Joseph
> Martinot-Lagarde" <joseph.martinot-lagarde at m4x.org>
> Cc:
>
> Dear all,
>
> after the first mailing list feedback, and further private discussion with
> Joseph Martinot-Lagarde, I drafted a first iteration of a PEP for keyword
> arguments in indexing. The document is available here.
>
> https://github.com/stefanoborini/pep-keyword/blob/master/PEP-XXX.txt
>
> The document is not in final form when it comes to specifications. In
> fact, it requires additional discussion about the best strategy to achieve
> the desired result. Particular attention has been devoted to present
> alternative implementation strategies, their pros and cons. I will examine
> all feedback tomorrow morning European time (in approx 10 hrs), and apply
> any pull requests or comments you may have.
>
> When the specification is finalized, or this community suggests that the
> PEP is in a form suitable for official submission despite potential open
> issues, I will submit it to the editor panel for further discussion, and
> deploy an actual implementation according to the agreed specification for a
> working test run.
>
> I apologize for potential mistakes in the PEP drafting and submission
> process, as this is my first PEP.
>
> Kind Regards,
>
> Stefano Borini
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140702/a3ce5e6f/attachment.html>


More information about the NumPy-Discussion mailing list