[issue18181] PEP447: Add type.__getdescriptor__

2016-07-24 Thread Ronald Oussoren

Changes by Ronald Oussoren :


Added file: http://bugs.python.org/file43853/pep447-2015-07-26.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18181] PEP447: Add type.__getdescriptor__

2015-07-26 Thread Ronald Oussoren

Ronald Oussoren added the comment:

Todays version of the patch adds more tests, especially for exceptions in 
__getdescriptor__ during the lookup of special methods.  Those tests were added 
because the C code couldn't get exceptions other than AttributeError before 
this patch and can get those know. This requires extra code, and hence extra 
tests (which exposed a number of crashers...).

The code should be solid now.

Note that the new error handling code isn't optimal style-wise, at some places 
I test for PyErr_Occurred() instead of adding error returns to functions now 
returning 'void' to keep the patch smaller and easier to review.

--
Added file: http://bugs.python.org/file40027/pep447-2015-07-26.txt

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



[issue18181] PEP447: Add type.__getdescriptor__

2015-07-25 Thread Ronald Oussoren

Ronald Oussoren added the comment:

I've attached a new version of the patch (pep447-2015-07-25.txt). Changes in 
this version of the patch:

1) Works with the current trunk (as in all tests pass)

2) Types in C must explicitly set Py_TPFLAGS_GETDESCRIPTOR in tp_flags to 
   enable the tp_getdescriptor slot. 

   This is primarily done avoid crashing when loading a C extension for
   older CPython versions (even if that's not guaranteed to work anyway).

The PEP needs to be updated for the second change, that's next on my list.

--
Added file: http://bugs.python.org/file40012/pep447-2015-07-25.txt

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



[issue18181] PEP447: Add type.__getdescriptor__

2015-07-25 Thread Ronald Oussoren

Ronald Oussoren added the comment:

Note: the error handling code for exceptions in __getdescriptor__ definitely 
isn't good enough yet. 

I'm writing tests and am hunting down the problems those tests find. I'm 
getting closer and will post a new version when I think I've found all bugs. 
Probably some time tomorrow.

For now be warned that unexpected exceptions in __getdescriptor__ might crash 
the interpreter, especially when it is used to look for dunder methods.

--

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



[issue18181] PEP447: Add type.__getdescriptor__

2015-07-25 Thread Ronald Oussoren

Ronald Oussoren added the comment:

The attached micro benchmark indicates that method_cache in typeobject.c isn't 
used when using my patch. I'll have too look into that.

Other than that benchmarks results look OK (but: not using the method_cache is 
unacceptable as this most definitely changes performance).

What is kind of scary, but is to be expected I guess, is that a 
__getdescriptor__ method in Python is awfully slow.  I have to look into why 
this is slow, as the slowdown for using Python is significantly worse than I 
expected.

--
Added file: http://bugs.python.org/file40013/pep447-micro-bench.py

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



[issue18181] PEP447: Add type.__getdescriptor__

2015-07-25 Thread Ronald Oussoren

Ronald Oussoren added the comment:

pep447-2015-07-25-v2.txt changes two things w.r.t. the patch earlier today:

1) The performance problems w.r.t. the method_cache are gone

2) Added code for handling python exceptions other than AttributeError in
   calls to __getdescriptor__. 

   This code requires some tests to make sure the error handling code 
   is correct.

The new patch also adds some more tests, and adds extra MCACHE_STATS counters. 
Those aren't part of the proposal but were helpful to find the problem w.r.t. 
1).

As I mentioned before implementing __getdescriptor__ in Python is bad for 
performance of instances of that metaclass. AFAIK that cannot be helped, doing 
that will just execute a lot more Python code.

--
Added file: http://bugs.python.org/file40017/pep447-2015-07-25-v2.txt

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