in reply to Re^2: Using 'keys' on a list
in thread Using 'keys' on a list
I liked your idea of adding a "baseline"!
I also really don't know either why generating the list of keys in the sub appears to be faster then giving the caller the ref and having him do it? I would have expected that difference to be smaller. Hopefully some other Monk knows?
I also really don't know either why generating the list of keys in the sub appears to be faster then giving the caller the ref and having him do it? I would have expected that difference to be smaller. Hopefully some other Monk knows?
However, the main point remains: If the caller needs the whole hash, give him a ref to a hash. This is much faster than passing the entire hash back as a list. Of course there are memory allocation issues with that because Perl will keep the memory for that hash allocated as long as there is reference to it.
Added: Except as a part of an object method, I don't know why a sub() in general would create a hash, only to just pass back just the keys? Seems a bit weird, but I'd also like to know why this appears to be somewhat faster.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Using 'keys' on a list
by GrandFather (Saint) on Jul 07, 2021 at 01:58 UTC | |
by Marshall (Canon) on Jul 08, 2021 at 17:56 UTC | |
by Marshall (Canon) on Jul 08, 2021 at 19:00 UTC | |
by swl (Parson) on Jul 08, 2021 at 23:17 UTC | |
by LanX (Saint) on Jul 09, 2021 at 16:08 UTC | |
by swl (Parson) on Jul 10, 2021 at 00:25 UTC | |
|
In Section
Seekers of Perl Wisdom