Skip to content

Unify #[pyfunction] and #[pyfn] #694

@davidhewitt

Description

@davidhewitt

It seems confusing to me to have two different attributes, #[pyfunction] and #[pyfn], which both wrap Rust functions to create python functions. Pyo3 users need to know which applies in two different contexts.

I'd argue we should merge these. Then there's only one attribute which pyo3 users need to know about. It would also help us to simplify / refactor the macro code if we didn't need two different parsing systems.

I think this would need to go in the following steps:

  1. Allow #[pyfunction] to be used in place of #[pyfn]
  2. Change the docs to describe #[pyfunction] everywhere
  3. Change #[pyfn] to expand to #[pyfunction]
  4. (Later on) change #[pyfn] to emit an error, stating the #[pyfunction] invocation to use instead
  5. (Much later on) remove #[pyfn]

I've already opened a PR #693 to achieve step 1.

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