[issue33265] contextlib.ExitStack abuses __self__

2018-04-13 Thread Nick Coghlan

Nick Coghlan  added the comment:

Classifying this as a minor performance enhancement, since methods are much 
simpler objects than full Python level closures.

Thanks!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type:  -> performance
versions: +Python 3.8

___
Python tracker 

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



[issue33265] contextlib.ExitStack abuses __self__

2018-04-13 Thread Nick Coghlan

Nick Coghlan  added the comment:


New changeset 23ab5ee667a9b29014f6f7f01797c611f63ff743 by Nick Coghlan 
(jdemeyer) in branch 'master':
bpo-33265: use an actual method instead of a method-like function in ExitStack 
(GH-6456)
https://github.com/python/cpython/commit/23ab5ee667a9b29014f6f7f01797c611f63ff743


--

___
Python tracker 

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



[issue33265] contextlib.ExitStack abuses __self__

2018-04-12 Thread Yury Selivanov

Yury Selivanov  added the comment:

Yep, I think this is a good fix!

--

___
Python tracker 

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



[issue33265] contextlib.ExitStack abuses __self__

2018-04-12 Thread Nick Coghlan

Nick Coghlan  added the comment:

Yury, could you double check the async exit stack change in the PR? I think 
it's fine since the bound method just passes back the underlying coroutine and 
the tests all still pass, but a second opinion would be good :)

--
nosy: +yselivanov

___
Python tracker 

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



[issue33265] contextlib.ExitStack abuses __self__

2018-04-12 Thread Eric V. Smith

Change by Eric V. Smith :


--
nosy: +ncoghlan

___
Python tracker 

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



[issue33265] contextlib.ExitStack abuses __self__

2018-04-11 Thread Jeroen Demeyer

Change by Jeroen Demeyer :


--
keywords: +patch
pull_requests: +6151
stage:  -> patch review

___
Python tracker 

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



[issue33265] contextlib.ExitStack abuses __self__

2018-04-11 Thread Jeroen Demeyer

New submission from Jeroen Demeyer :

In contextlib, there is code which roughly looks like

def _exit_wrapper(exc_type, exc, tb):
return cm_exit(cm, exc_type, exc, tb)
_exit_wrapper.__self__ = cm

This creates a new function _exit_wrapper from a given function cm_exit by 
prepending the __self__ attribute to *args. Now this is exactly what a method 
does too.

It would be better to use an actual method for this: it's cleaner, faster and 
it doesn't abuse a double-underscore attribute. The latter will actually break 
with PEP 575, as __self__ will become a special name  instead of an arbitrary 
attribute.

--
components: Library (Lib)
messages: 315212
nosy: jdemeyer
priority: normal
severity: normal
status: open
title: contextlib.ExitStack abuses __self__

___
Python tracker 

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