Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callable.assuming() is slow #5369

Open
p6rt opened this issue Jun 11, 2016 · 3 comments
Open

Callable.assuming() is slow #5369

p6rt opened this issue Jun 11, 2016 · 3 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jun 11, 2016

Migrated from rt.perl.org#128388 (status was 'open')

Searchable as RT128388$

@p6rt
Copy link
Author

p6rt commented Jun 11, 2016

From @hinrik

Calling .assuming() on a subroutine is way too slow for general usage.

$ time perl6 -e'sub foo { my &curry = &foo.assuming(); }; for 1..100 -> $x { foo() }'

real 0m4.235s
user 0m4.192s
sys 0m0.044s

$ time perl6 -e'sub foo { }; for 1..100 -> $x { foo() }'
real 0m0.106s
user 0m0.068s
sys 0m0.036s

@p6rt
Copy link
Author

p6rt commented Jun 12, 2016

From @smls

Agreed.

It's also not thread-safe (see ticket #​127987), and its implementation is a real mess of spaghetti code.
I think it's a safe bet that at some point that whole method will be rewritten, and that'll hopefully fix its slowness too.

For now, you can use a closure instead. So for example instead of this​:

  my &float-to-str = &sprintf.assuming("%f");

...write this​:

  my &float-to-str = { sprintf "%f", $_ };

In the general case (when you don't know how many and what type of variable parameters will be passed), the following two should behave the same​:

  &f.assuming($a, $b)

  -> |c { f $a, $b, |c }

@p6rt
Copy link
Author

p6rt commented Jun 12, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt p6rt added the perf label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant