in reply to Why is "any" slow in this case?
is a coderef that refers only to global variables, so is compiled once and (presumably) only one CV ever exists for this compiled code.any { $1 == $_ }
is a coderef that refers to lexical variables, and so on every iteration it has some overhead to link the lexical scope to the coderef. I don't know the exact details of what that entails, but if you consider the possibility that the 'any' function could store those code references in a list somewhere, I think it means there is a newly allocated CV on every iteration.any { $c == $_ }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why is "any" slow in this case?
by LanX (Saint) on Jul 31, 2025 at 21:21 UTC | |
by NERDVANA (Priest) on Aug 02, 2025 at 18:32 UTC | |
by ikegami (Patriarch) on Aug 05, 2025 at 01:52 UTC | |
by LanX (Saint) on Aug 04, 2025 at 21:28 UTC |