Author: Arianna Avanzini <avanzini.aria...@gmail.com> Branch: rpython-sprint Changeset: r93998:76a4a4c1f521 Date: 2018-03-19 09:57 +0100 http://bitbucket.org/pypy/pypy/changeset/76a4a4c1f521/
Log: Document enforceargs() decorator on RPython docs. diff --git a/rpython/doc/rpython.rst b/rpython/doc/rpython.rst --- a/rpython/doc/rpython.rst +++ b/rpython/doc/rpython.rst @@ -259,6 +259,26 @@ intmask(). +Type Enforcing and Checking +--------------------------- + +RPython provides a helper decorator to force RPython-level types on function +arguments. The decorator, called `enforceargs()`, accepts as parameters the +types expected to match the arguments of the function. + +Functions decorated with `enforceargs()` have their function signature analyzed +and their RPython-level type inferred at import time (for further details about +the flavor of translation performed in RPython, see the +`Annotation pass documentation`_). Encountering types not supported by RPython +will raise a `TypeError`. + +`enforceargs()` by default also performs type checking of parameter types each +time the function is invoked. To disable this behavior, it's possible to +pass the `typecheck=False` parameter to the decorator. + +.. _Annotation pass documentation: http://rpython.readthedocs.io/en/latest/translation.html#annotator + + Exception rules --------------- _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit