[Numpy-discussion] How is NumPy implemented?
Geoffrey Zhu
gzhu at peak6.com
Thu Jun 28 17:00:02 EDT 2007
I see. Thanks a lot.
-----Original Message-----
From: numpy-discussion-bounces at scipy.org
[mailto:numpy-discussion-bounces at scipy.org] On Behalf Of Tom Denniston
Sent: Thursday, June 28, 2007 3:33 PM
To: Discussion of Numerical Python
Subject: Re: [Numpy-discussion] How is NumPy implemented?
That is normal python syntax. It works with lists. What is slightly
unusual is the multi-dimensional slicing as in arr[:,10:20]. However,
this is governed by the way python translates bracket[] index calls to
the __getitem__ and __getslice__ methods. You can try it out yourself
in ipython or your favorite interpretter by writing the following
class:
In [4]: class GetItemInspect(object):
...: def __getitem__(self, slices):
...: print slices
...:
...:
In [5]: GetItemInspect()[:,:,10:]
(slice(None, None, None), slice(None, None, None), slice(10, None,
None))
This allows you to play with the translation semantics. I'm sure they
are also documented somewhere but I usually find trying many examples
helpful.
--Tom
On 6/28/07, Geoffrey Zhu <gzhu at peak6.com> wrote:
> Hi All,
>
> I am curious how numpy is implemented. Syntax such as x[10::-2] is
> completely foreign to Python. How does numpy get Python to support it?
>
> Thanks,
> Geoffrey
>
> PS. Ignore the disclaimer. The mail server automatically insert that.
>
> _______________________________________________________=0A=
> =0A=
> The information in this email or in any file attached=0A= hereto is
> intended only for the personal and confiden-=0A= tial use of the
> individual or entity to which it is=0A= addressed and may contain
> information that is propri-=0A= etary and confidential. If you are
> not the intended=0A= recipient of this message you are hereby notified
> that=0A= any review, dissemination, distribution or copying of=0A=
> this message is strictly prohibited. This communica-=0A= tion is
> for information purposes only and should not=0A= be regarded as an
> offer to sell or as a solicitation=0A= of an offer to buy any
> financial product. Email trans-=0A= mission cannot be guaranteed to be
> secure or error-=0A= free. P6070214
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion at scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
More information about the NumPy-Discussion
mailing list