On Aug 12, 2009, at 9:04 AM, Christopher Barker wrote: > Robert Bradshaw wrote: >> The Cython philosophy is that one should be able to take a piece of >> Python code, compile it with Cython, maybe sprinkle in some static >> type declarations, and the behavior should be essentially the same > > I, for one, like this approach, which is why I was surprised by the > None > issue. > > If I write a python function that expects a numpy array, and I pass a > None into it, I'll get an exception. > > If I write a Cython function that expects a numpy array and declare > that > in the function signature, then pass a None it, I get a bus error (or > who knows what other ugly crash).
The difference in behavior is that an exception is raised as soon as the function is entered, vs. somewhere down the line. Of course, a hard crash vs. a Python exception (at the wrong spot or not) is pretty glaring, but the plan is to change that. On Aug 12, 2009, at 9:31 AM, Christopher Barker wrote: > Christopher Barker wrote: > >> NOTE: it would be a good idea to add that to examples and >> tutorials, too. > > In the spirit of putting my time where my mouth is, I just updated the > numpy tutorial with "non None" information: > > http://wiki.cython.org/tutorials/numpy > > please edit, or roll back if you don't like it. Thanks! - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
