[plt-scheme] Contracts performance

From: Robby Findler (robby at cs.uchicago.edu)
Date: Thu Jul 3 15:18:37 EDT 2008

On Thu, Jul 3, 2008 at 2:14 PM, Mark Engelberg <mark.engelberg at gmail.com> wrote:
> I'm trying to get my head around the performance overhead associated
> with contracts.  I noticed in the manual it talks about the space
> overhead between returning any vs. any/c in a tail-call recursive
> function.  Are there some other common "gotchas"?

I don't think so.

> How about (listof
> any) and related contracts?  Is that O(1) or O(n)?

(listof any) cannot be O(1) without some more help from the mzscheme
runtime system, I believe. You're probably thinking of the contract
(or/c pair? null?), but (listof any) needs to make sure it actually
has a list (ie all of the cdr position of any pair has either a pair
or null). But maybe Matthew has added something and I've just missed
the chance to take advantage of it? I know there was something about
making the list? predicate be constant time? Anyways, (listof any)
isn't constant time.

> Furthermore, if you turn off debugging information, does contract
> checking go away as well?

No, contracts don't go away unless you take them away.
Robby


Posted on the users mailing list.