On Oct 8, 2009, at 6:04 AM, Dag Sverre Seljebotn wrote: > I experience this: > > <Py_ssize_t>np.sqrt(some_float64) > => TypeError: 'numpy.float64' object cannot be interpreted as an > index > > However > a) <int>np.sqrt(...) works fine, as does <long> and <long long>. > b) In Python, int(np.sqrt(...)) and long(np.sqrt(...)) both works > fine > > Is Py_ssize_t "special" when it comes to converting from Python > objects? > If so I find it mildly confusing and something which only increases > learning curve...
Py_ssize_t is meant for indexing, and fails for the same reason that >>> L = range(10) >>> L[2] 2 >>> L[2.5] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: list indices must be integers, not float fails. This is a feature, not a bug. - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
