Re: [racket-users] Speeding up the conversion of flvectors to string

2021-06-28 Thread Sam Tobin-Hochstadt
On Mon, Jun 28, 2021 at 9:46 PM Jonathan Simpson wrote: > > On Sunday, June 27, 2021 at 10:29:55 AM UTC-4 Robby Findler wrote: >> >> Replacing ` (~r x #:precision 1)` with `(number->string x)` and ditto for >> `y` eliminates the overhead of contracts and brings about another 4x speedup >> on my

Re: [racket-users] Speeding up the conversion of flvectors to string

2021-06-28 Thread Jonathan Simpson
On Sunday, June 27, 2021 at 10:29:55 AM UTC-4 Robby Findler wrote: > Replacing ` (~r x #:precision 1)` with `(number->string x)` and ditto for > `y` eliminates the overhead of contracts and brings about another 4x > speedup on my machine. > This is because the compiler is able to remove the con

Re: [racket-users] Speeding up the conversion of flvectors to string

2021-06-28 Thread Robby Findler
I think you found a slowdown that's just a severe as the one we've been talking about and, once that one'd been cleared up, you might have seen the other one, perhaps in the calls to string-append. But you are right that some costs (like gc) are smeared out across the whole computation and thus har

Re: [racket-users] Speeding up the conversion of flvectors to string

2021-06-28 Thread Alessandro Motta
On 27.06.21 19:34, Robby Findler wrote: > On Sun, Jun 27, 2021 at 11:58 AM Alessandro Motta > wrote: > > I also like Jens' code for its pure functional elegance. I'm surprised > that building up a long list of short strings before joining them is so > much f

Re: [racket-users] Top-level unbound identifiers during expansion

2021-06-28 Thread Greg Rosenblatt
Thanks Sam. I ended up finding another alternative, which is to replace the set!-followed-by-define with define-values: (define-values (name.r ...) (values (lambda (param ...) body ...) ...)) One more related question (though given the hopelessness, I'd understand if there isn't a great answe

Re: [racket-users] Top-level unbound identifiers during expansion

2021-06-28 Thread Sam Tobin-Hochstadt
This is indeed an issue where "the top-level is hopeless" is the problem [1]. However, there's a better work-around. You can write `(define-syntaxes (name.r ...) (values))` to forward-declare all those names, and then the subsequent definitions will work correctly. Sam [1] https://lists.racket-l

Re: [racket-users] Speeding up the conversion of flvectors to string

2021-06-28 Thread Bogdan Popa
Bogdan Popa writes: > Ah! You're right. When I make the change you suggest, the program > takes 5s to run. Filed under "Accidentally Not Quadratic" 😅. The program actually takes 2.5s to run. I missed the fact that I had made two separate calls to `string-append!` in that version of the prog