[issue7830] Flatten nested functools.partial

2015-03-01 Thread STINNER Victor
STINNER Victor added the comment: I forgot this issue. Thanks for the enhancement. It will help asyncio for example. It was surprised the first time i tested nested partial. -- ___ Python tracker ___

[issue7830] Flatten nested functools.partial

2015-03-01 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- resolution: -> fixed stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Python

[issue7830] Flatten nested functools.partial

2015-03-01 Thread Roundup Robot
Roundup Robot added the comment: New changeset 7839681ca931 by Alexander Belopolsky in branch 'default': Issue #7830: Flatten nested functools.partial. https://hg.python.org/cpython/rev/7839681ca931 -- nosy: +python-dev ___ Python tracker

[issue7830] Flatten nested functools.partial

2014-10-08 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I've updated the patch. -- keywords: +patch Added file: http://bugs.python.org/file36837/issue7830-2.diff ___ Python tracker ___ __

[issue7830] Flatten nested functools.partial

2014-10-07 Thread STINNER Victor
Changes by STINNER Victor : -- nosy: +haypo type: enhancement -> performance ___ Python tracker ___ ___ Python-bugs-list mailing list U

[issue7830] Flatten nested functools.partial

2014-10-06 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I would say that getting "maximum recursion depth exceeded" error from evaluating a deeply nested partial is a bug, but I am not sure we should fix it by flattening partial objects in the constructor or by being smarter at evaluation time. -- co

[issue7830] Flatten nested functools.partial

2014-10-06 Thread Josh Rosenberg
Josh Rosenberg added the comment: The use case in question, simplified, was: from functools import partial class Foo: Bar = othermodule.Bar def __new__(cls, ...): ... cls.Bar(...) ... def bind_stuff(cls, *args, **kwargs): cls.Bar = partial(Bar, *arg

[issue7830] Flatten nested functools.partial

2014-10-06 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Josh, Would issue7830.diff solve your use-case as is? See msg108980 for the limitations. If so, I don't mind reopening this issue. -- ___ Python tracker __

[issue7830] Flatten nested functools.partial

2014-10-06 Thread Josh Rosenberg
Josh Rosenberg added the comment: If it affects the decision, I just had to debug some code at work that triggered a "excessive recursion" bug because they used functools.partial over and over on the same base function, thinking they could safely replace some keyword bindings over and over. Th

[issue7830] Flatten nested functools.partial

2010-11-30 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: The original motivation for the patch was that if partial() objects are guaranteed to be flat, it would simplify code that deals with them. See issue4331 for one example. With a "conservative" patch, however, it will still be possible to create nested

[issue7830] Flatten nested functools.partial

2010-11-30 Thread Raymond Hettinger
Raymond Hettinger added the comment: Alexander, I don't see anything wrong with patch, nor anything compelling about it either. It's your choice whether or not to apply. -- ___ Python tracker ___

[issue7830] Flatten nested functools.partial

2010-07-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > FWIW, I agree with Antoine. You cannot know in advance whether a > partial-subclass has semantics that need to be preserved when > flattening. Raymond, I have actually conceded this point to Antoine. See msg108980 above. Not only the latest patch p

[issue7830] Flatten nested functools.partial

2010-07-23 Thread Raymond Hettinger
Raymond Hettinger added the comment: Antoine> Flattening should only happen for instances of the exact type. FWIW, I agree with Antoine. You cannot know in advance whether a partial-subclass has semantics that need to be preserved when flattening. -- nosy: +rhettinger ___

[issue7830] Flatten nested functools.partial

2010-07-23 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Since I am the OP of this patch, I would like a +1 from another developer before checking this in. (Or a couple of -1s before rejecting:-) Antoine, Does the latest patch address your concerns? Virgil, If you care enough about this feature, please po

[issue7830] Flatten nested functools.partial

2010-07-23 Thread Virgil Dupras
Virgil Dupras added the comment: Oops, used it wrong (but it still works correctly). >>> p2 = partial(p1, 2) >>> p2.func, p2.args (, (1, 2)) -- ___ Python tracker ___ _

[issue7830] Flatten nested functools.partial

2010-07-23 Thread Virgil Dupras
Virgil Dupras added the comment: Applies cleanly on the py3k branch at r83069, the tests work correctly (fail before applying the patch, success afterwards), and, to the best of my C-API knowledge, the C code is alright. Oh, and it behaves as described... Python 3.2a0 (py3k:83069M, Jul 23 20

[issue7830] Flatten nested functools.partial

2010-06-30 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I am attaching a patch, issue7830.diff, that takes an ultra-concervative approach: partials are only flattened if both outer and inner are of exact functools.partial type and the inner partial does not have __dict__. -- assignee: -> belopolsky

[issue7830] Flatten nested functools.partial

2010-02-01 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Antoine> Flattening should only happen for instances of the exact type. I am attaching a variant of the patch that will only flatten if both nested and wrapping partial is of the exact type. Other possibilities would include flattening partial_subtype(f

[issue7830] Flatten nested functools.partial

2010-02-01 Thread Antoine Pitrou
Antoine Pitrou added the comment: Flattening should only happen for instances of the exact type. When people create subclasses, there's usually a reason for it. -- nosy: +pitrou ___ Python tracker

[issue7830] Flatten nested functools.partial

2010-02-01 Thread Alexander Belopolsky
New submission from Alexander Belopolsky : Currently applying functools.partial to a callable that is already functools.partial object results in a nested object: >>> from functools import partial >>> def f(a,b,c): pass ... >>> p = partial(partial(f, 1), 2) >>> p.func, p.args (, (2,)) Propos