11 Optimization in Typed Racket

▼ |  | The Typed Racket Reference

1 | Type Reference
2 | Special Form Reference
3 | Libraries Provided With Typed Racket
4 | Typed Classes
5 | Typed Units
6 | Utilities
7 | Exploring Types
8 | Deep, Shallow, and Optional Semantics
9 | Typed Racket Syntax Without Type Checking
10 | Typed Regions
11 | Optimization in Typed Racket
12 | Unsafe Typed Racket operations
13 | Legacy Forms
14 | Compatibility Languages
15 | Experimental Features
| Bibliography
| Index

► | 11 | Optimization in Typed Racket

11.1 | Contract Optimization

On this page:

11.1`` Contract Optimization

8.17
top contents ← prev up next →

### 11`` Optimization in Typed Racket🔗ℹ

See Optimization in Typed Racket in the guide for tips to get the most out of the optimizer.

Typed Racket provides a type-driven optimizer that rewrites well-typed programs to potentially make them faster.

Typed Racket’s optimizer is turned on by default. If you want to deactivate it (for debugging, for instance), you must add the #:no-optimize keyword when specifying the language of your program:

> #lang typed/racket #:no-optimize

The optimizer is also disabled if the environment variable PLT_TR_NO_OPTIMIZE is set (to any value) or if the current code inspector (see Code Inspectors) is insufficiently powerful to access racket/unsafe/ops, for example when executing in a sandbox (see Sandboxed Evaluation). This prevents untrusted code from accessing these operations by exploiting errors in the type system.

#### 11.1`` Contract Optimization🔗ℹ

Typed Racket generates contracts for its exports to protect them against untyped code. By default, these contracts do not check that typed code obeys the types. If you want to generate contracts that check both sides equally (for analysis, for teaching, etc.) then set the environment variable PLT_TR_NO_CONTRACT_OPTIMIZE to any value and recompile.

top contents ← prev up next →