[pythran] question on slice.hpp

  • From: Neal Becker <ndbecker2@xxxxxxxxx>
  • To: pythran@xxxxxxxxxxxxx
  • Date: Thu, 4 Sep 2014 14:32:22 -0400

In pythran/pythonic/types/slice.hpp

            long size() const
                assert( not upper.is_none and not lower.is_none and not
step.is_none );
                return std::max(0L, long(ceil(double(upper -

Maybe this should be:
(using python code here:)

def roundup_divide (a, b):
    return (a + b - 1) // b

return std::max(0L, roundup_divide (upper-lower, step));

But on the other hand, did you really mean to roundup?  Should the size of
a slice be rounded down?

*Those who don't understand recursion are doomed to repeat it*

Other related posts: