On Tue, Dec 08, 2020 at 11:46:59AM -0000, Mathew Elman wrote: > I would like to propose adding lazy types for casting builtins in a > lazy fashion. e.g. `lazy_tuple` which creates a reference to the > source iterable and a morally immutable sequence but only populates > the tupular container when it or the source is used.
What are your use-cases for this? Does this include things like `lazy_list`, `lazy_float`, `lazy_bool`, `lazy_str`, `lazy_bytearray` etc? > An alternative to adding lazy types / lazy type casting (making it > possible to implement these oneself) would be to add method call hooks > to python, since this would allow having a "freeze value" callback > hooked into the __setitem__ and __getitem__ methods. Hooks may be a > more useful solution for wider use cases as well. Nope, sorry, I don't see how that would work. Here I have a list: L = [50, 40, 30, 20, 10] Suppose these hooks exist. I want to make a "lazy tuple": t = lazy_tuple(L) How do these hooks freeze the list? What if I have more than one lazy object pointing at the same source? s = lazy_str(L) And then follow with a different method call? L.insert(2, "surprise!") I just can't see how this will work. -- Steve _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/6OLOHQBMYVPQSDAI5HRTRBVJRKDYB4QM/ Code of Conduct: http://python.org/psf/codeofconduct/