[Python-Dev] Pre- and post-conditions
Marko Ristin-Kaufmann
marko.ristin at gmail.com
Wed Aug 15 04:25:17 EDT 2018
Hi python devs,
I would be very interested to bring design-by-contract into python 3. I
looked at some of the packages I found on pypi and also we rolled our own
solution (https://github.com/Parquery/icontract/). I also looked into
https://www.python.org/dev/peps/pep-0316/.
However, all these solutions seem quite clunky to me. The decorators
involve an unnecessary computational overhead and the implementation of
icontract became quite tricky once we wanted to get the default values of
the decorated function.
What do you think about the following solution as an extension to python
compiler / interpreter?
* We specify pre- and post-conditions in the docstring.
* Python interpreter parses these conditions and adapts the corresponding
byte codes at the begining and the end of the function body.
I'm very grateful for any feedback on this!
Marko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180815/8c604e93/attachment.html>
More information about the Python-Dev
mailing list