On 29/01/20 8:37 am, John Skaller2 wrote:
If I implement that with just static casts for coercions, then say, given a dictionary and a function accepting a mapping argument, you can pass a dictionary or mapping, but not an object. If you want to pass an object you have to explicitly coerce it.
That sounds fine. Cython follows similar rules.
The *problem* with this idea I think is that from memory the reference counting rules for PyObject and dictionaries are not the same as for methods on abstractions.
The vast majority of CPython API functions follow consistent refcounting rules -- they take borrowed references as arguments, and return new references as return values. However, a few of the low-level functions that operate on specific types follow different rules. Cython knows about these and treats them specially. For your system, you may need a way of annotating function declarations with refcounting rules where they differ from the defaults. -- Greg _______________________________________________ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel