Re: [C++-sig] Re: vector_indexing_suite too defensive ...
by Joel de Guzman other posts by this author
Sep 29 2003 4:06PM messages near this date
Re: [C++-sig] On wrapping vector >
|
[C++-sig] Re: (no subject)
Raoul Gough <RaoulGough@[...].uk> wrote:
> "Joel de Guzman" <djowel@[...].uk> writes:
>
> > Mike Thompson <mike.thompson@[...].au> wrote:
> [snip]
> >> The IndexError arises because vector_indexing_suite defends against
> >> an slice index being too big, rather than the python list approach
> >> which regards a slice index > len(L) as equal to len(L). So, the
> >> line of padOrChop() which says:
> >>
> >> lst[size:] = [padValue] * diff
> >>
> >> causes an exception when size > len(lst).
> >>
> >> Should vector_indexing_suite be altered to give behaviour more like
> >> that of lists in this regard?
> >
> > It should. I think you uncovered a vector_indexing_suite bug. I'll
> > correct this as soon as I can.
>
> Hi Joel,
>
> You might find the PySlice_GetIndices function useful - it take a
> Python slice object and a container length and returns normalized
> start and stop values (even handling negative indices, IIRC). At a
> guess, this is probably how the Python list works internally too.
I *was* using PySlice_GetIndices. The problem was (if I'm not mistaken),
is that it does not handle non-integer inteces. Correct me if I'm wrong.
For example, I have a case where the indexes are dates that I must convert
to a valid index.
--
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net
_______________________________________________
C++-sig mailing list
C++-sig@[...].org
http://mail.python.org/mailman/listinfo/c++-sig
|