Still compiling use cases. But I will use your (@blhsing) suggestion from another thread and do pros and cons of deferred evaluation attempts
So there have been several deferred proposals/paths explored:
1. Lazy object based deferred evaluation
Progress:
- I have experimented with Python level implementations for a while
- They had drawbacks, but Backquotes for deferred expression has fixed them
- It hit the wall of functioning at
Clevel and hasn’t moved forward yet
2. Lazy evaluation via Type Annotations
Progress:
3. Lazy defaults via extra parameter
Already available
4. “Just use lambda”
Already available
5. this - lazy object for signalling, but explicit handling is needed
Progress:
- Been using this approach in various places for a while without any issues
Pros/Cons
| Pros Cons
+-------------------------------------------
(1) Implicit Complex
Intuitive Uncertain if can be implemented without Python 4
Nesting Too complex and advanced given current actual needs
(2) Implicit Complexity at parser level
Breaks conventions in undesirable manner
Adds undesirable weight on parser
No attempt at implementation has been made yet
Unlikely to work for extensions
(3) Explicit Verbose
Already exists Inconvenient
Noone uses it despite being available
e.g. why does not `dict.get` have
extra argument for lazy default?
Does not ensure consistent standard
e.g. parameter naming
Extra parameter might be troublesome for some cases
e.g. `assert`
Needs Explicit Handling that
developers need to implement for each case
(4) Explicit Various issues mentioned in
Already Exists https://discuss.python.org/t/builtins-lazy-for-lazy-arguments/86577/67
Just think about issues enabling `dict.get`
to accept lambda as lazy argument
Simply unsuitable to be "one way to do it"
Needs Explicit Handling that
developers need to implement for each case
(5) Explicit Needs Explicit Handling that
Simple developers need to implement for each case
Easily Achievable Relies on mutual agreement to use the same object
Imposes desirable
consistency
Does not have issues
mentioned in
https://discuss.python.org/t/builtins-lazy-for-lazy-arguments/86577/67
Maintains good enough
performance