[Python-ideas] Why is design-by-contracts not widely adopted?

Steven D'Aprano steve at pearwood.info
Sat Sep 29 05:06:44 EDT 2018

On Wed, Sep 26, 2018 at 05:40:45AM +1000, Chris Angelico wrote:

> > There are 150K projects on pypi.org. Each one of them would benefit 
> > if annotated with the contracts.
> This is the extraordinary claim. To justify it, you have to show that
> virtually ANY project would benefit from contracts. So far, I haven't
> seen any such proof.

As per my previous email, I think the extraordinary claim is that there 
exists even a single project which wouldn't benefit from at least one 

Honestly, you sound almost like somebody saying 

    "Projects would benefit from getting an automated test 
    suite? Ridiculous!"

But to give you a charitable interpretation, I'll grant that given the 
cost to benefit ratio of code churn, human effort, refactoring etc, it 
is certainly possible that adding contracts to some especially mature 
and high-quality projects, or quick-and-dirty low-quality projects where 
nobody cares about bugs, would cost more than the benefit gained. 
There's benefit, but not *nett* benefit.

That goes especially for Python code since the available interfaces for 
contracts are so poor. But that's why we're talking about this on 

I just wish we didn't have to fight so hard to justify the very idea of 
contracts themselves. That's like having to justify the idea of test 
suites, documentation and error checking.


More information about the Python-ideas mailing list