Skip to content

Cython 3.0a6 causes hangs with function framework #373

Description

@jacklovell

Cython 3.0a6 has changed the way binary operators such as __add__ are implemented: https://cython.readthedocs.io/en/latest/src/changes.html#alpha-6-2020-07-31. They now follow Python semantics rather than the C API semantics. This has caused issues with using the function objects in Raysect. For example:

from raysect.core.math.function.float import Arg2D, Exp2D
f = Exp2D(Arg2D('x'))
f * 2 # Returns MultiplyFunction2D instantly
2 * f # Hangs at 100% CPU

I've been able to fix this by adding the c_api_binop_methods=True Cython directive to raysect's setup.py, but I don't know if this is a backwards-compatible solution. The alternative is to implement __radd__ etc. in the function frameworks: these will be ignored by Cython 0.x and the old behaviour maintained, whereas in Cython 3.x these functions will be called. They can just call the existing __add__ etc. functions with the arguments in the correct order.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions