@@ -698,6 +698,31 @@ between old unannotated code and new versions of libraries which do use
698698these type annotations.
699699
700700
701+ Alternatives
702+ ============
703+
704+ It should be noted that the approach outlined in this PEP to solve the
705+ issue of shape checking in numerical libraries is *not * the only approach
706+ possible. Examples of lighter-weight alternatives based on *runtime * checking include
707+ ShapeGuard [#shapeguard ]_, tsanley [#tsanley ]_, and PyContracts [#pycontracts ]_.
708+
709+ While these existing approaches improve significantly on the default
710+ situation of shape checking only being possible through lengthy and verbose
711+ assert statements, none of them enable *static * analysis of shape correctness.
712+ As mentioned in `Motivation `_, this is particularly desirable for
713+ machine learning applications where, due to library and infrastructure complexity,
714+ even relatively simple programs must suffer long startup times; iterating
715+ by running the program until it crashes, as is necessary with these
716+ existing runtime-based approaches, can be a tedious and frustrating
717+ experience.
718+
719+ Our hope with this PEP is to begin to codify generic type annotations as
720+ an official, language-supported way of dealing with shape correctness.
721+ With something of a standard in place, in the long run, this will
722+ hopefully enable a thriving ecosystem of tools for analysing and verifying
723+ shape properties of numerical computing programs.
724+
725+
701726Backwards Compatibility
702727=======================
703728
@@ -809,6 +834,12 @@ References
809834 .. [#arbitrary_len ] Discussion on Python typing-sig mailing list:
810835 https://mail.python.org/archives/list/typing-sig@python.org/thread/SQVTQYWIOI4TIO7NNBTFFWFMSMS2TA4J/
811836
837+ .. [#tsanley ] tsanley: https://github.com/ofnote/tsanley
838+
839+ .. [#pycontracts ] PyContracts: https://github.com/AndreaCensi/contracts
840+
841+ .. [#shapeguard ] ShapeGuard: https://github.com/Qwlouse/shapeguard
842+
812843 .. _cpython/23527 : https://github.com/python/cpython/pull/24527
813844
814845.. _mrahtz/cpython/pep637+646 : https://github.com/mrahtz/cpython/tree/pep637%2B646
0 commit comments