Skip to content

Implement "@nogil" as decorator in pure Python mode #2557

@scoder

Description

@scoder

Implement this:

@cython.cfunc
@cython.nogil
def func() -> cython.int:
    return 1
  • Add nogil to the list of directives in Cython/Compiler/Options.py.
  • In the AdjustDefByDirectives tree transformation, apply the nogil directive wherever the nogil modifier is allowed, i.e. cdef/@cfunc and cpdef/@ccall functions.
  • Wherever decorators are allowed, but nogil is not, reject it explicitly (because it is no longer rejected by the parser).
  • Write tests for the good cases and for invalid cases.
  • Optionally: allow @nogil on Python (def) functions and interpret it as with nogil.

Also see #2579.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions