How to make a Racket type tayped faster?
The racket is fast. But when I use Typed Racket and run the code, I find that the type checking is slow.
For example, run this code from Rocket Ticket Guide
#lang typed/racket (struct: pt ([x : Real] [y : Real])) (: distance (-> pt pt Real)) (define (distance p1 p2) (sqrt (+ (sqr (- (pt-x p2) (pt-x p1))) (sqr (- (pt-y p2) (pt-y p1))))))
It takes 4-6 seconds to work on my computer (i7, 4g ram)
I tried another computer and still
Did I make some mistake? How can I make type checking faster?
+3
source to share
1 answer
Unfortunately, there is nothing that can be changed to make the type checker run faster. If you use #lang typed/racket/base
instead #lang typed/racket
, things might be a little faster. But for various reasons, the Typed Racket typechecker has to solve some tricky problems and therefore not so quickly.
+1
source to share