[Python-ideas] Contracts in python -- a report & next steps
chris.barker at noaa.gov
Wed Oct 24 15:29:54 EDT 2018
On Wed, Oct 24, 2018 at 12:57 AM, Chris Angelico <rosuav at gmail.com> wrote:
> For the sake of those of us who REALLY don't feel like diving back
> into the extensive threads on this subject, can you please summarize
> the benefits of having this in the stdlib rather than as a third-party
I'm not (currently) a fan of design by contract, and don't expect I'll end
up using it, whether or not we get a nifty standard library for it....
That being said -- this is analogous to why PEP 484 -- Type Hints was
adopted, even though the syntax changes in Python had long been adopted to
That is: the IF folks are going to use DbC in Python, the community is MUCH
better off if everyone does it in the same way. And the way to make that
happen is to put it in the stdlib.
However, I'm not sure it's anywhere near time to actually do that -- before
we get there, there needs to be a pretty good community of folks using
icontract (or maybe something else?) and ideally some interest from a core
developer or two.
After all, PEP 484 didn't get rollling until Guido got interested in MyPy.
But by all means -- start building that community -- maybe some of us
skeptics will be drawn in ....
> Also - have you benchmarked the performance cost of adding contracts?
> Particularly: if you're planning to contractify the stdlib, what is
> the impact on startup performance?
Contractifying the stdlib is an entirely independent question -- yes, if
we wanted to add contract to the stdlib, we'd need a contract library in
the stdlib, but there's no need for the other way around to be true.
Is the stdlib being fully typhinted since PEP 484 was added? a quick scan
of the PEP didn't seem to mention it at all.
Performance (particularly start up time) would absolutely be a
consideration if and when we get there, but I don't know that it has any
impact to anything anyone might do now.
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas