[C++-sig] boost/python/slice.hpp
Jonathan Brandmeyer
jbrandmeyer at earthlink.net
Thu Jul 8 19:21:53 CEST 2004
On Thu, 2004-07-08 at 13:06, Ralf W. Grosse-Kunstleve wrote:
> --- Jonathan Brandmeyer <jbrandmeyer at earthlink.net> wrote:
> > On Thu, 2004-07-08 at 12:32, Jonathan Brandmeyer wrote:
> > > Since ret.stop is guaranteed to be a multiple of ret.step away from
> > > ret.start, this statement should get it for you (the signs also work out
> > > in the reverse case):
> > >
> > > int size = (ret.stop - ret.start) / ret.step;
> >
> > And since it is an inclusive range, make that:
> > int size = (ret.stop - ret.start) / ret.step + 1;
>
> I think this would make a very useful member function.
> Ralf
Due to the possibilities from negative and PyNone values in a slice, the
only place that you can reliably compute it is in get_indicies(). It
would be added to the returned struct.
-Jonathan
More information about the Cplusplus-sig
mailing list