WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
229148
[webkitcorepy] Add CallByNeed object
https://bugs.webkit.org/show_bug.cgi?id=229148
Summary
[webkitcorepy] Add CallByNeed object
Jonathan Bedard
Reported
2021-08-16 09:31:52 PDT
It's often the case that we want to defer the computation of an object until we actually need that object. We should add a small wrapper object that allows us to do this in webkitcorepy.
Attachments
Patch
(8.36 KB, patch)
2021-08-16 09:43 PDT
,
Jonathan Bedard
no flags
Details
Formatted Diff
Diff
Patch
(8.31 KB, patch)
2021-08-18 08:24 PDT
,
Jonathan Bedard
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Jonathan Bedard
Comment 1
2021-08-16 09:33:27 PDT
<
rdar://problem/81817705
>
Jonathan Bedard
Comment 2
2021-08-16 09:43:09 PDT
Created
attachment 435612
[details]
Patch
dewei_zhu
Comment 3
2021-08-17 16:34:08 PDT
Comment on
attachment 435612
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=435612&action=review
> Tools/Scripts/libraries/webkitcorepy/webkitcorepy/defer.py:24 > +class Defer(object):
It might cause confusion with "Deferred" in twisted module, which is more about async operation. For this one, we want to defer the evaluation of 'callback', this is more like lazily evaluated. This also limits the callback to be a callable that takes no argument, would that work for what it's designed for?
> Tools/Scripts/libraries/webkitcorepy/webkitcorepy/tests/defer_unittest.py:34 > +
Maybe we also want to have a test case that the evaluation is actually deferred. value = [] d = Defer(lambda: value.append('foo')) self.assertEqual(len(value), 0) d.value self.assertEqual(len(value), 1) self.assertEqual(value[0], 'foo').
Jonathan Bedard
Comment 4
2021-08-18 08:24:17 PDT
Created
attachment 435768
[details]
Patch
Jonathan Bedard
Comment 5
2021-08-18 09:34:09 PDT
Committed
r281191
(
240635@main
): <
https://commits.webkit.org/240635@main
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug