Re: Negative array indicies and slice()

Discussion in 'Python' started by Ian Kelly, Nov 1, 2012.

  1. Ian Kelly

    Ian Kelly Guest

    On Thu, Nov 1, 2012 at 5:32 AM, Andrew Robinson
    <> 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 thatoften 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.
    Ian Kelly, Nov 1, 2012
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    88888 Dihedral
    Nov 2, 2012
  2. Andrew Robinson

    Re: Negative array indicies and slice()

    Andrew Robinson, Oct 29, 2012, in forum: Python
    Andrew Robinson
    Oct 29, 2012
  3. Mark Lawrence

    Re: Negative array indicies and slice()

    Mark Lawrence, Oct 29, 2012, in forum: Python
    Mark Lawrence
    Oct 29, 2012
  4. Ethan Furman

    Re: Negative array indicies and slice()

    Ethan Furman, Oct 30, 2012, in forum: Python
    Ethan Furman
    Oct 30, 2012
  5. Dennis Lee Bieber

    Re: Negative array indicies and slice()

    Dennis Lee Bieber, Oct 31, 2012, in forum: Python
    Dennis Lee Bieber
    Oct 31, 2012

Share This Page