ANN: Design By Contract for Python 1.0 beta 1

Chuck Swiger cswiger at mac.com
Mon May 26 14:21:31 EDT 2003


Jeff Epler wrote:
[ ... ]
> Of course, even this may radically slow your program.  For instance, sort()
> is presumably O(n lg n) runtime complexity, but the precondition that tests
> that each pair of items is comparable is O(n^2) complexity.

If the comparision operation isn't transitive, the notion of sorting 
becomes moot: the notion of partial and total ordering depends on it. 
An O(n) test that verifies that all of the things being sorted can be 
compared to something (say the first element) should suffice.

-- 
-Chuck







More information about the Python-list mailing list