On Fri, May 15, 2020 at 05:44:59PM -0700, Andrew Barnert wrote:

> Once you go with a separate view-creating function (or type), do we even need 
> the dunder?

Possibly not. But the beauty of a protocol is that it can work even if 
the object doesn't define a `__view__` dunder.

- If the object defines `__view__`, call it; this allows objects to 
  return an optimized view, if it makes sense to them; e.g. bytes 
  might simply return a memoryview.

- If not, fall back on a generic view object that just does index 
  arithmetic and delegation.



-- 
Steven
_______________________________________________
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/4R5CRI2MJP3R4PZPDRTDZFYOCDPSP3I2/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to