[issue18181] super vs. someclass.__getattribute__

2013-07-15 Thread Ronald Oussoren

Ronald Oussoren added the comment:

There now is a PEP for this issue: http://www.python.org/dev/peps/pep-0447/.

The current version of the PEP describes a different API than documented by the 
attached proposal and the prove of concept code. I'm working on an updated 
implementation.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-07-15 Thread Ronald Oussoren

Ronald Oussoren added the comment:

issue18181-locallookup-only-super.txt implements the current version of PEP 
447, but only for the super object. In this version of the  patch normal 
attribute lookup (object.__getattribute__ and PyObject_GenericGetAttr) are not 
yet affected.

Another open issue: the documentation for the super object itself does not yet 
mention __locallookup__; it probably should but I don't know yet how to cleanly 
add it there.

--
Added file: 
http://bugs.python.org/file30928/issue18181-locallookup-only-super.txt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-07-04 Thread Ronald Oussoren

Ronald Oussoren added the comment:

Updated version of the patch, with some semantic changes and tests for the 
Python level API.

Known issues:

* Patches uses tabs for indentation

* No tests for the C level API

* I don't like implementation of slot_tp_getattro_super

--
Added file: http://bugs.python.org/file30766/issue-18181-poc-v4.txt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-07-04 Thread Ronald Oussoren

Changes by Ronald Oussoren ronaldousso...@mac.com:


Removed file: http://bugs.python.org/file30546/issue-18181-poc.txt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-07-04 Thread Ronald Oussoren

Changes by Ronald Oussoren ronaldousso...@mac.com:


Removed file: http://bugs.python.org/file30555/issue-18181-poc-v3.txt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-07-04 Thread Ronald Oussoren

Changes by Ronald Oussoren ronaldousso...@mac.com:


Removed file: http://bugs.python.org/file30528/supers.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-07-04 Thread Ronald Oussoren

Changes by Ronald Oussoren ronaldousso...@mac.com:


Removed file: http://bugs.python.org/file30556/super-hook-proposal.rst

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-07-04 Thread Ronald Oussoren

Ronald Oussoren added the comment:

Also updated the draft PEP text

--
Added file: http://bugs.python.org/file30767/super-hook-proposal.rst

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-06-12 Thread Ronald Oussoren

Ronald Oussoren added the comment:

added draft of a pep-style proposal

--
Added file: http://bugs.python.org/file30556/super-hook-proposal.rst

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-06-12 Thread Ronald Oussoren

Ronald Oussoren added the comment:

Slightly updated patch (different names, added some documentation)

--
Added file: http://bugs.python.org/file30555/issue-18181-poc-v3.txt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-06-11 Thread Ronald Oussoren

Ronald Oussoren added the comment:

I've attached a first very rough patch to demonstrate what I was rambling about.

With this patch and a patched version of PyObjC I can use the builtin super 
class with the proxy classes for Objective-C classes.

Open issues:

* Does this need a pep?

* The name of the new slot sucks, need to find a better one

* Should it be possible to define the slot in Python code?

  Probably, the 'super.py' file is a crude hack but I can imagine
  more realistic scenarios where implementing the slot in Python
  would be useful.

* There are no tests, and no documentation updates

--
keywords: +patch
Added file: http://bugs.python.org/file30546/issue-18181-poc.txt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-06-11 Thread Ronald Oussoren

Ronald Oussoren added the comment:

Second version of the poc adds a way to implement the hook in Python code, and 
supers_updated.py uses that hook.

Still no tests, no documentation and with awfull naming :-)

--
Added file: http://bugs.python.org/file30547/supers_updated.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-06-11 Thread Ronald Oussoren

Ronald Oussoren added the comment:

.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-06-11 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

Is it possible to avoid a new slot?
for example, super() could walk the tp_base- chain and call tp_getattro each 
time the value changes.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-06-11 Thread Ronald Oussoren

Ronald Oussoren added the comment:

I don't think it is possible to avoid adding a new slot. The default 
implementation of tp_getattro (PyObject_GenericGetAttr) looks in the instance 
dict, while super does not (because it wants a less specific implementation).  

PyObject_GenericGetAttr will also walk the entire MRO, while 
super.__getattribute__ does not start search at the first entry in the MRO.

Although I'd love to be proven wrong ;-)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-06-10 Thread Ronald Oussoren

New submission from Ronald Oussoren:

Super() walks the MRO and looks for the looked-up attribute in the __dict__ of 
types on the MRO. This can cause problems when classes implement 
__getattribute__: a class on the MRO can implement a method that super() won't 
find because it isn't in the class __dict__ (yet).

I'm running into this with PyObjC: the __dict__ for the Python proxies for 
Objective-C classes are filled lazily (*) by tp_getattro (__getattribute__ in 
Python) to speed up the bridge and because ObjC is almost as dynamic as Python 
and methods might appear during runtime (without there being a hook for 
detecting such changes).

A possible solution to this:

* Add a tp_getattro_super (**) slot to PyTypeObject, with the 
  same signature as tp_getattro, but that only looks at this particular
  class (as opposed to tp_getattro that walks the entire MRO and looks
  in the object's __dict__)  (***)

* The tp_gettro of super calls tp_getattro_super of types of along the
  MRO when that slot is not NULL, and uses the current implementation
  (look in tp_dict) when the slot is NULL.

Would such a change be acceptable?

Open issues:

* Does the new slot get exposed to Python code 
  (and if so, under which name)?

* Should PyObject_GenericGetAttr use the new slot as well?


Footnotes:

(*) The current release of PyObjC (2.5) eagerly tries to keep the proxy class 
__dict__ up to date, an upcoming major release will be as lazy as possible to 
speed up the bridge. The problem can with some effert be triggered with PyObjC 
2.5, and triggering it is easy in the upcoming major release

(**) Or some better name

(***) I'm being very sloppy in my use of terminology here, hopefully my 
proposal is clear enough anyway.

--
components: Interpreter Core
messages: 190905
nosy: ronaldoussoren
priority: normal
severity: normal
stage: needs patch
status: open
title: super vs. someclass.__getattribute__
type: behavior
versions: Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-06-10 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

Do you have an example in pure Python code?

--
nosy: +amaury.forgeotdarc

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-06-10 Thread Ronald Oussoren

Ronald Oussoren added the comment:

I didn't, but the attached script should do the trick. The code suffers badly 
from copypaste editing, but more or less has the same behavior as PyObjC.

It defines a subclass of list (MyList) with an append method, and more 
importantly also defines 3 proxy classes: ProxyObject, ProxyList and 
ProxyMyList that are proxy types for object, list and MyList.

At the end I try to access methods on instances of a proxy objects for MyList, 
and finally try to access super(MyList, v).append. That only works when 
append is in the __dict__ for ProxyList (for example by uncommenting the 3 
lines just above the use of super()).

--
Added file: http://bugs.python.org/file30528/supers.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-06-10 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

issue783528 was a bit similar.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] super vs. someclass.__getattribute__

2013-06-10 Thread Ronald Oussoren

Ronald Oussoren added the comment:

Looks like it. That issue was closed without a good reason though.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18181
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com