There was a patch for slow in-connections IIRC https://github.com/racket/racket/pull/3599 Is it possible that it is not shipped with racket8.0?
That definitely appeared in 8.0; see the tag mentioned on https://github.com/racket/racket/commit/6ace62a717ace50acb7b7ff7e3e63f80192ed27b
But it’s still embarrassingly slow
Can you time the individual lines in python?
My suspicion is you’re just seeing startup in for Racket
in python? or in racket?
FWIW, found-2020
is (define (found-2020 [l : (Listof Integer)]) : (U Integer False)
(and (eq? 2020 (apply + l))
(apply * l)))
The times reported includes reading the file in both languages, which might be a secondary concern. I would try to time only the relevant bits (python has a timeit
module, IIRC). I would try to make the programs do exactly the same thing, and (someone correct me if I’m wrong) but maybe compiling the racket example ahead-of-time would make a difference?
IOW comparing times is hard
I don’t intend to race the two languages, but this much difference is huge. So I should know how to avoid the startup lag in Racket
Right; I’m suppose in a convoluted way I’m suggesting part of the difference is Racket’s startup time, which is apples-and-oranges to python, maybe?
Not targeted at you specifically, but a good read: https://ericlippert.com/2012/12/17/performance-rant/
yes, indeed, when I prepend a print “hello” to the start of the program it appears just 2 seconds after the start
Is there a way to reduce/avoid the startup time
Since your program is in Typed Racket, that’s mostly typechecking time
you can reduce it by running raco make <whatever>.rkt
But that will not reduce it to the level of Python
But it should make you happier
so: I should explicitly call raco to create bytecode (unlike eg. python)
and yes, even with bytecode available it’s above 0.8s
yes, macro expansion and compilation are both slower than in python
and also, the standard library is mostly in Racket so it takes longer to load
and also you’re using typed/racket which loads a bunch more code
and racket’s module loading semantics imply more load-time cost than Python (I think)
So does typed/racket effects runtime performance and not just a compile-time checker?
Typed Racket affects runtime performance in two ways: 1. startup time code (Typed Racket is code that has to be loaded at startup because that’s how languages in Racket work, it’s a lot of code because that’s life) 2. contract checks: if you use require/typed
or provide
values to untyped clients
@pihentagy if your use case involves needing to run many short scripts, one way to avoid the startup lag is to start Racket once, and then have it accept commands from standard input. Scripting languages like Python & Ruby will probably always have an edge re: startup lag.
@yoeskastyle has joined the channel
Can someone help me with this
Determine the perimeter of each of the figures present in a list of points, and for each one of them save it as data, with an identifier or name, the perimeter and the set of points that make up the figure.
I have to draw in scheme, but I really don’t know how
Which book are you following?
can be draw.rkt or htdp / image
Yes - but what book are you following?
A SICP style solution will look different from an HTDP style one.
I did not understand your question very well, but the language in which I have to do it is scheme in drracket, to do the exercise I have to do it with draw.rkt maybe this https://docs.racket-lang.org/teachpack/draw.html
Use the new library: https://docs.racket-lang.org/teachpack/2htdpimage.html
@petchar has joined the channel