Skip to content

Reference handling #16

@encukou

Description

@encukou

Most of this is already in the devguide.

Rules for new API:

Function arguments

Functions must not steal references to their arguments.
IOW, after a function call, the caller still owns the arguments it passed in.

The caller must guarantee that references stay valid for the entire call.

Return values and "output parameters" (*result)

Functions returning references must return a new reference.
IOW, after a function call, the caller owns (a reference to) the return value.

Same rules apply to filling an output parameter (*result, #13).

Borrowed references

We're likely to have exceptions to these rules (#4) which create borrowed references.
These must be documented, and the documentation must explicitly state what the reference is borrowed "from" and how long it is valid for. (Even if it's like None can be borrowed from the interpreter so it's valid until interpreter shutdown.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    guidelineTo be included in guidelines PEP

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions