Skip to content

[DISC] Use type annotations in cython #22180

Closed
@jbrockmendel

Description

@jbrockmendel

Regardless of whether run in py2/py3, cython supports modern type annotations. A lot of _libs could be made valid python by using these.

Upsides:

  • linting!
  • get experience with these, will help in deciding if we want to use them in the non-cython code-base.
  • may lower barrier-to-entry for contributors not comfortable with cython

Downsides:

  • If it works, don't fix it
  • Until fully implemented, we'd have mix-and-match conventions
  • cython's pure-python mode has more rough edges than its regular mode
  • in some cases the valid-python versions get pretty verbose:
cdef inline bint is_integer_object(object obj) nogil:
    cdef:
         int foo

vs.

@cython.cfunc
@cython.inline
@cython.nogil
def is_integer_object(tz: object) -> bint:
    foo: int

The main upside I see is the linting. My inclination is to try to implement it in a subset of files where we can get close to pure-python as a test run.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsInternalsRelated to non-user accessible pandas implementationNeeds DiscussionRequires discussion from core team before further action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions