A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2014-March/133304.html below:

[Python-Dev] Making proxy types easier to write and maintain

[Python-Dev] Making proxy types easier to write and maintain [Python-Dev] Making proxy types easier to write and maintainAntoine Pitrou solipsis at pitrou.net
Wed Mar 19 21:22:42 CET 2014
On Wed, 19 Mar 2014 19:32:50 +0000
Brett Cannon <bcannon at gmail.com> wrote:
> >
> > In http://bugs.python.org/issue19359#msg213530 I proposed to introduce a
> > "proxy
> > protocol" (__proxy__ / tp_proxy) that would be used as a fallback by
> > _PyObject_LookupSpecial to fetch the lookup target, i.e.:
> >
> > def _PyObject_LookupSpecial(obj, name):
> >     tp = type(obj)
> >     try:
> >         return getattr(tp, name)
> >     except AttributeError:
> >         return getattr(tp.tp_proxy(), name)
> >
> > What do you think?
> >
> 
>  Without having the code in front of me, would this only be for magic
> methods and attributes, or all attributes? IOW would this mean that if I
> assign an object to __proxy__ it would take care of the uses of __getattr__
> for proxying?

In a first approach it would be only for magic methods and attributes.
It if proves successful, perhaps it can be later expanded to also be
used for regular lookups.

By the way, Benjamin pointed me to a prior discussion:
http://bugs.python.org/issue643841

Regards

Antoine.
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4