Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #32570

Re: Negative array indicies and slice()

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'bug.': 0.07; 'implements': 0.07; 'indices': 0.07; 'rejected': 0.07; 'type,': 0.07; 'python': 0.09; '2006.': 0.09; 'already.': 0.09; 'integers': 0.09; 'length.': 0.09; 'pep': 0.09; 'subject:()': 0.09; 'subtle': 0.09; 'tuple.': 0.09; 'bug': 0.10; 'index': 0.13; 'adjusts': 0.16; 'btw:': 0.16; 'container,': 0.16; 'dump': 0.16; 'hmmmm....': 0.16; 'invoking': 0.16; 'merely': 0.16; 'numpy': 0.16; 'report?': 0.16; 'subject:array': 0.16; 'trivially': 0.16; 'wrote:': 0.17; 'fix': 0.17; 'implementing': 0.17; 'thu,': 0.17; 'tim': 0.18; 'code.': 0.20; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'implemented': 0.27; 'separate': 0.27; 'andrew': 0.27; 'object,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'lines': 0.28; 'container': 0.29; 'crash': 0.29; 'yes.': 0.29; 'usually': 0.30; 'implement': 0.32; 'could': 0.32; '2006': 0.33; 'int': 0.33; 'to:addr:python-list': 0.33; 'weeks': 0.33; 'version': 0.34; 'received:google.com': 0.34; 'nov': 0.35; 'sequence': 0.35; 'doing': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'really': 0.36; 'but': 0.36; 'wanted': 0.36; 'method': 0.36; 'too': 0.36; 'itself': 0.37; 'does': 0.37; 'uses': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'apply': 0.39; 'release': 0.39; 'takes': 0.39; 'header:Received:5': 0.40; 'is.': 0.62; 'strange': 0.62; 'between': 0.63; 'more': 0.63; 'behavior': 0.64; 'risk': 0.66; 'hand': 0.82; '2.5.': 0.84; 'blown': 0.84; 'syndrome': 0.84; 'to:name:python': 0.84; 'ethan': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=gjJXykPPITET+5Vd96ADmpjcV74Zpgwsw9IKj7K/624=; b=E9Mhwo2mHh/naNjWB4GP7b66HIWJ6Gf9Nodi4HMSZ2AwIbtAQpFCD9bvUObkiCQg6j Tv1Ot79y2stVhV6urblALbDWmGt6e7VrHbNox/7FPEqfbb9HVHXCDmwUwP6pimV3FbUG Zxv1ppYXEODay26eP9LoCF2nN1pxh0IKOktJ+36n1n+ySl7SBJ91wbot7bN3yVCkxSui Blj4EIB3uaQuMZj7fjR3j7HcF9UkrXHLBsDZSjJgGrTYv8RM/7Oa81upRMJaN1je9fxR gMlU26/aOboGgJ4h7/YmTtWXFjlBvIEjxysclZP2SsVfjO1dw2VVttXW06Fux8uNDfGt UNpA==
MIME-Version 1.0
In-Reply-To <50925DE6.7020100@r3dsolutions.com>
References <509053F2.6020900@r3dsolutions.com> <CALwzidnQ2bUdMp8c0xNomabcLHZBBtr_DYSSzvhz3jqeYNkWkQ@mail.gmail.com> <50912ADC.2020401@r3dsolutions.com> <CALwzid=_1TCQC5JryemVfVpBLWq=qZwy4hRjCPA5ha0vSm3=VA@mail.gmail.com> <50918716.3080305@r3dsolutions.com> <5092833F.4070609@stoneleaf.us> <50925DE6.7020100@r3dsolutions.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Thu, 1 Nov 2012 13:07:32 -0600
Subject Re: Negative array indicies and slice()
To Python <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3163.1351796884.27098.python-list@python.org> (permalink)
Lines 37
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1351796884 news.xs4all.nl 6929 [2001:888:2000:d::a6]:60145
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:32570

Show key headers only | View raw


On Thu, Nov 1, 2012 at 5:32 AM, Andrew Robinson
<andrew3@r3dsolutions.com> wrote:
> Hmmmm.... was that PEP the active state of Python, when Tim rejected the bug report?

Yes. The PEP was accepted and committed in March 2006 for release in
Python 2.5.  The bug report is from June 2006 has a version
classification of Python 2.5, although 2.5 was not actually released
until September 2006.

> Pep 357 merely added cruft with index(), but really solved nothing.  Everything index() does could be implemented in __getitem__ and usually is.

No.  There is a significant difference between implementing this on
the container versus implementing it on the indexes.  Ethan
implemented his string-based slicing on the container, because the
behavior he wanted was specific to the container type, not the index
type.  Custom index types like numpy integers on the other hand
implement __index__ on the index type, because they apply to all
sequences, not specific containers.  This must be separate from
standard int conversion, because standard int conversion is too
general for indexing.

> slice is also a full blown object, which implements a trivial method to dump the contents of itself to a tuple.

slice.indices() does not trivially dump its contents as given.  It
takes a sequence length and adjusts its indices to that length.  The C
implementation of this is around 60 lines of code.

> Don't bother to fix the bug; allow Python to crash with a subtle bug that often take weeks to track down by the very small minority doing strange things (Equivalent to the "monkey patch" syndrome of D'Aprano; BTW: The longer the bug is left unfixed, the more people will invent "uses" for it )

It's been 6 years already.  AFAIK nobody has invented any uses that
are actually at risk of invoking the GC bug.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Negative array indicies and slice() Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-01 13:07 -0600

csiph-web