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
Proxy objects - frequent FETCHs #4704
Comments
From @dwarringConsider the following, which should be a simple and conventional use of Perl 6 Proxy objects: class C { has $!bar; my $c = C.new; OUTPUT: FETCHES =================== In particular, the proxy FETCH is called 7X to do a simple increment. I'm raising this because this is the 'hot path' in projects such as https://github.com/p6-pdf/perl6-PDF-Tools. Would like to see this reduced, if possible. |
From @dwarringCorrect to test case, (say in wrong position): class C { has $!bar; Proxy.new( my $c = C.new; On Sat Oct 31 12:09:05 2015, david.warring wrote:
|
From @dwarringHere's an attempt at bench-marking proxy objects, vs a simple home-baked accessor: use Bench; has $!bar; my $c = C.new; Bench.new.cmpthese(1000, { # results Benchmark: Proxys look like an expensive option at the moment. On Sat Oct 31 13:45:28 2015, david.warring wrote:
|
From @MadcapJakeMadcapJake> m: class N { method text { return Proxy.new: FETCH => method () { say 'fetch: ', ++$ }, STORE => method ($new) { say "$new: ", ++$ } } }; N.text; N.text = 'blah'; On Sat Oct 31 12:09:05 2015, david.warring wrote:
|
From @dwarringOn Fri, 22 Apr 2016 21:35:33 -0700, madcap.russo+p6@gmail.com wrote:
Related is a failed attempt to subclass Proxy with a caching version: my class ProxyCache is Proxy { method FETCH { class C { has $!bar; my $c = C.new; But no luck. My caching methods aren't called. Output is unchanged. |
You can't apparently not subclass Proxy, according to #5911 |
This has become now: m: class N { method text { return-rw Proxy.new: FETCH => method () { say 'fetch: ', ++$ },STORE => method ($new) { say "$new: ", ++$ } } }; N.text; N.text = 'blah';
# OUTPUT: «fetch: 1fetch: 2fetch: 3blah: 1» Still the same error, though. It's fetching 3 times. |
Migrated from rt.perl.org#126520 (status was 'new')
Searchable as RT126520$
The text was updated successfully, but these errors were encountered: