Re: [Python-Dev] PEP 362: 4th edition

2012-06-19 Thread Larry Hastings
On 06/18/2012 07:35 PM, Yury Selivanov wrote: BTW, http://bugs.python.org/issue15008 has the latest implementation attached (if anybody wants to play with it) I've also posted the latest minor tweaks to the PEP, on behalf of Yury. The new version is already live: http://www.python.org/de

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Yury Selivanov
On 2012-06-18, at 10:06 PM, Nick Coghlan wrote: > On Tue, Jun 19, 2012 at 12:00 PM, Yury Selivanov > wrote: >> On 2012-06-18, at 9:36 PM, Nick Coghlan wrote: >>> So keep the current copying semantics for Signature objects (i.e. >>> creating new copies of the Parameter objects as well), but call

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Nick Coghlan
On Tue, Jun 19, 2012 at 12:00 PM, Yury Selivanov wrote: > On 2012-06-18, at 9:36 PM, Nick Coghlan wrote: >> So keep the current copying semantics for Signature objects (i.e. >> creating new copies of the Parameter objects as well), but call it a >> shallow copy rather than a deep copy. Make it cle

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Steven D'Aprano
On Mon, Jun 18, 2012 at 02:09:17PM -0400, Yury Selivanov wrote: > That's an excerpt from Signature.__deepcopy__: > > cls = type(self) > sig = cls.__new__(cls) > sig.parameters = OrderedDict((name, param.__copy__()) \ >for name, param in self.parameters.i

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Yury Selivanov
On 2012-06-18, at 9:36 PM, Nick Coghlan wrote: > On Tue, Jun 19, 2012 at 4:09 AM, Yury Selivanov > wrote: >> On 2012-06-18, at 1:35 PM, PJ Eby wrote: >>> Then just copy the signature itself; as currently written, this is going to >>> copy the annotation objects, which could produce weird side-e

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Yury Selivanov
On 2012-06-18, at 9:50 PM, Steven D'Aprano wrote: > On Mon, Jun 18, 2012 at 07:10:33PM -0400, Yury Selivanov wrote: > >> It seems that we have the following options for 'signature(obj)': >> >> 1. If 'obj' has a '__signature__' attribute - return a copy of it, >> if not - create a new one. >> >

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Steven D'Aprano
On Mon, Jun 18, 2012 at 07:10:33PM -0400, Yury Selivanov wrote: > It seems that we have the following options for 'signature(obj)': > > 1. If 'obj' has a '__signature__' attribute - return a copy of it, > if not - create a new one. > > 2. If 'obj' has a '__signature__' attribute - return it, > i

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Nick Coghlan
On Tue, Jun 19, 2012 at 4:09 AM, Yury Selivanov wrote: > On 2012-06-18, at 1:35 PM, PJ Eby wrote: >> Then just copy the signature itself; as currently written, this is going to >> copy the annotation objects, which could produce weird side-effects from >> introspection.  Using deepcopy seems lik

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Yury Selivanov
On 2012-06-18, at 9:29 PM, Nick Coghlan wrote: > On Tue, Jun 19, 2012 at 7:06 AM, Jim Jewett wrote: >> Correct; it should be redundant. Signature.kwargsparameter should be >> the same object that occurs as the nth element of >> Signature.parameters.values(). It is just more convenient to retrie

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Nick Coghlan
On Tue, Jun 19, 2012 at 7:06 AM, Jim Jewett wrote: > Correct; it should be redundant.  Signature.kwargsparameter should be > the same object that occurs as the nth element of > Signature.parameters.values().  It is just more convenient to retrieve > the parameter directly than it is to iterate thr

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Ethan Furman
Yury Selivanov wrote: On 2012-06-18, at 4:25 PM, Guido van Rossum wrote: On Mon, Jun 18, 2012 at 11:09 AM, Yury Selivanov wrote: The rationale is that sometimes you need to modify signatures. For instance, in decorators. A decorator should make a modified copy, not modify it in place (since

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Nick Coghlan
On Mon, Jun 18, 2012 at 5:08 PM, Jim Jewett wrote: > On Sat, Jun 16, 2012 at 11:27 AM, Nick Coghlan wrote: >> No. This is the full set of binding behaviours. "self" is just an >> ordinary "POSITIONAL_OR_KEYWORD" argument (or POSITIONAL_ONLY, in some >> builtin cases). > > Or no longer a "paramete

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Yury Selivanov
On 2012-06-18, at 4:25 PM, Guido van Rossum wrote: > On Mon, Jun 18, 2012 at 11:09 AM, Yury Selivanov > wrote: >> The rationale is that sometimes you need to modify signatures. >> For instance, in decorators. > > A decorator should make a modified copy, not modify it in place (since > the signat

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Yury Selivanov
Jim, On 2012-06-18, at 5:06 PM, Jim Jewett wrote: > On Mon, Jun 18, 2012 at 10:37 AM, Yury Selivanov > wrote: >> Jim, >> >> On 2012-06-18, at 3:08 AM, Jim Jewett wrote: >>> On Sat, Jun 16, 2012 at 11:27 AM, Nick Coghlan wrote: On Sat, Jun 16, 2012 at 1:56 PM, Jim J. Jewett wrote: >

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Jim Jewett
On Mon, Jun 18, 2012 at 10:37 AM, Yury Selivanov wrote: > Jim, > > On 2012-06-18, at 3:08 AM, Jim Jewett wrote: >> On Sat, Jun 16, 2012 at 11:27 AM, Nick Coghlan wrote: >>> On Sat, Jun 16, 2012 at 1:56 PM, Jim J. Jewett wrote:    Instead of defining a BoundArguments class, just return

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Guido van Rossum
On Mon, Jun 18, 2012 at 11:09 AM, Yury Selivanov wrote: > The rationale is that sometimes you need to modify signatures. > For instance, in decorators. A decorator should make a modified copy, not modify it in place (since the signature of the decorated function does not change, and you have no g

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Yury Selivanov
On 2012-06-18, at 1:35 PM, PJ Eby wrote: > On Fri, Jun 15, 2012 at 5:03 PM, R. David Murray > wrote: > On Fri, 15 Jun 2012 22:48:42 +0200, Victor Stinner > wrote: > > > 1. Should we keep 'Parameter.implemented' or not. *Please vote* > > -1 to implemented. > > > I still disagree with the dee

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread PJ Eby
On Fri, Jun 15, 2012 at 5:03 PM, R. David Murray wrote: > On Fri, 15 Jun 2012 22:48:42 +0200, Victor Stinner < > victor.stin...@gmail.com> wrote: > > > 1. Should we keep 'Parameter.implemented' or not. *Please vote* > > -1 to implemented. > > > I still disagree with the deepcopy. I read somewhere

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Yury Selivanov
Jim, On 2012-06-18, at 3:08 AM, Jim Jewett wrote: > On Sat, Jun 16, 2012 at 11:27 AM, Nick Coghlan wrote: >> On Sat, Jun 16, 2012 at 1:56 PM, Jim J. Jewett wrote: > >>>Instead of defining a BoundArguments class, just return >>> a copy of the Signature, with "value" attributes added to >>

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Nick Coghlan
On Mon, Jun 18, 2012 at 5:08 PM, Jim Jewett wrote: > But perhaps they *should* know their relative position. No, relative position is a property of the Signature - a parameter has no position until it is made part of a signature. > Also, > positional_only, *args, and **kwargs should be able to r

Re: [Python-Dev] PEP 362: 4th edition

2012-06-18 Thread Jim Jewett
On Sat, Jun 16, 2012 at 11:27 AM, Nick Coghlan wrote: > On Sat, Jun 16, 2012 at 1:56 PM, Jim J. Jewett wrote: >>    *Every* Parameter attribute is optional, even name. >>  (Think of  builtins, even if they aren't automatically >>supported yet.)   So go ahead and define some others >>th

Re: [Python-Dev] PEP 362: 4th edition

2012-06-16 Thread Terry Reedy
On 6/16/2012 6:40 PM, Yury Selivanov wrote: Actually, Signature and Parameter are currently non-hashable (they are mutable). I'm not sure if it was a right decision. If this is added for 3.3, I think it would be a candidate for 'provisional' (ie, api subject to change) status. (That is not t

Re: [Python-Dev] PEP 362: 4th edition

2012-06-16 Thread Yury Selivanov
On 2012-06-16, at 11:27 AM, Nick Coghlan wrote: > On Sat, Jun 16, 2012 at 1:56 PM, Jim J. Jewett wrote: >> >> Summary: >> >>*Every* Parameter attribute is optional, even name. (Think of >>builtins, even if they aren't automatically supported yet.) >>So go ahead and define some othe

Re: [Python-Dev] PEP 362: 4th edition

2012-06-16 Thread Yury Selivanov
Jim, On 2012-06-15, at 11:56 PM, Jim J. Jewett wrote: > because: >def f(*, a=4, b=5): pass > > and: >def f(*, b=5, a=4): pass > > should probably have equal signatures. That's a very good catch -- I'll fix the implementation. >> * bind(\*args, \*\*kwargs) -> BoundArguments >>Create

Re: [Python-Dev] PEP 362: 4th edition

2012-06-16 Thread Nick Coghlan
On Sat, Jun 16, 2012 at 1:56 PM, Jim J. Jewett wrote: > > Summary: > >    *Every* Parameter attribute is optional, even name.  (Think of >    builtins, even if they aren't automatically supported yet.) >    So go ahead and define some others that are sometimes useful. No, that's not the right att

Re: [Python-Dev] PEP 362: 4th edition

2012-06-16 Thread Daniel Urban
On Sat, Jun 16, 2012 at 5:56 AM, Jim J. Jewett wrote: > I think it should be explicit that this mapping does not include > parameters which would be filled by default arguments.  In fact, if > you stick with this interface, I would like a 3rd method that does > fill out everything. +1 Daniel __

[Python-Dev] PEP 362: 4th edition

2012-06-15 Thread Jim J. Jewett
Summary: *Every* Parameter attribute is optional, even name. (Think of builtins, even if they aren't automatically supported yet.) So go ahead and define some others that are sometimes useful. Instead of defining a BoundArguments class, just return a copy of the Signature, w

Re: [Python-Dev] PEP 362: 4th edition

2012-06-15 Thread Victor Stinner
> Right now we have no way to automatically generate signatures for built-in > functions.  So, as of current trunk, any such signatures would have to be > built by hand. > > If we could somehow produce signature information in C, what then?  Two > possible approaches suggest themselves: > > Pre-gen

Re: [Python-Dev] PEP 362: 4th edition

2012-06-15 Thread Christian Heimes
Am 15.06.2012 23:38, schrieb Yury Selivanov: > Although, Larry added __signature__ attribute to PyCFunctionObject > (None by default_. So those, who want to manually create signatures > for their 'C' functions would be able to do that. As I explained in my other posting: You can't add a mutable

Re: [Python-Dev] PEP 362: 4th edition

2012-06-15 Thread Steven D'Aprano
Yury Selivanov wrote: Hello, The new revision of PEP 362 has been posted: http://www.python.org/dev/peps/pep-0362/ Open questions: 1. Should we keep 'Parameter.implemented' or not. *Please vote* -0.5 It is easier to add it later if it is needed, then to take it away if not needed. 2

Re: [Python-Dev] PEP 362: 4th edition

2012-06-15 Thread Christian Heimes
Am 15.06.2012 23:03, schrieb R. David Murray: > The issue isn't "consenting adults", the issue is consistency. > Without the deepcopy, sometimes what you get back from the > inspect function is freely modifiable and sometimes it is not. > That inconsistency is a bad thing. This must be addressed o

Re: [Python-Dev] PEP 362: 4th edition

2012-06-15 Thread Larry Hastings
On 06/15/2012 02:13 PM, Antoine Pitrou wrote: I'm not sure I understand. The PEP already says signatures are computed lazily. Is there an exception for built-in functions? Right now we have no way to automatically generate signatures for built-in functions. So, as of current trunk, any such

Re: [Python-Dev] PEP 362: 4th edition

2012-06-15 Thread Yury Selivanov
On 2012-06-15, at 5:35 PM, Yury Selivanov wrote: > On 2012-06-15, at 5:30 PM, Antoine Pitrou wrote: > >> On Fri, 15 Jun 2012 17:26:25 -0400 >> Yury Selivanov wrote: >> >>> On 2012-06-15, at 5:13 PM, Antoine Pitrou wrote: >>> On Fri, 15 Jun 2012 17:07:46 -0400 Yury Selivanov wrote: >

Re: [Python-Dev] PEP 362: 4th edition

2012-06-15 Thread Yury Selivanov
On 2012-06-15, at 5:30 PM, Antoine Pitrou wrote: > On Fri, 15 Jun 2012 17:26:25 -0400 > Yury Selivanov wrote: > >> On 2012-06-15, at 5:13 PM, Antoine Pitrou wrote: >> >>> On Fri, 15 Jun 2012 17:07:46 -0400 >>> Yury Selivanov wrote: On 2012-06-15, at 4:48 PM, Victor Stinner wrote: [sn

Re: [Python-Dev] PEP 362: 4th edition

2012-06-15 Thread Antoine Pitrou
On Fri, 15 Jun 2012 17:26:25 -0400 Yury Selivanov wrote: > On 2012-06-15, at 5:13 PM, Antoine Pitrou wrote: > > > On Fri, 15 Jun 2012 17:07:46 -0400 > > Yury Selivanov wrote: > >> On 2012-06-15, at 4:48 PM, Victor Stinner wrote: > >> [snip] > >>> Would it be possible to only create a signature

Re: [Python-Dev] PEP 362: 4th edition

2012-06-15 Thread Yury Selivanov
On 2012-06-15, at 5:13 PM, Antoine Pitrou wrote: > On Fri, 15 Jun 2012 17:07:46 -0400 > Yury Selivanov wrote: >> On 2012-06-15, at 4:48 PM, Victor Stinner wrote: >> [snip] >>> Would it be possible to only create a signature for builtin the first >>> time that you read its __signature__ attribute?

Re: [Python-Dev] PEP 362: 4th edition

2012-06-15 Thread Antoine Pitrou
On Fri, 15 Jun 2012 17:07:46 -0400 Yury Selivanov wrote: > On 2012-06-15, at 4:48 PM, Victor Stinner wrote: > [snip] > > Would it be possible to only create a signature for builtin the first > > time that you read its __signature__ attribute? I don't know how to > > implement such behaviour on a b

Re: [Python-Dev] PEP 362: 4th edition

2012-06-15 Thread Yury Selivanov
On 2012-06-15, at 4:48 PM, Victor Stinner wrote: [snip] > Would it be possible to only create a signature for builtin the first > time that you read its __signature__ attribute? I don't know how to > implement such behaviour on a builtin function. I don't know if it's > important to decide this rig

Re: [Python-Dev] PEP 362: 4th edition

2012-06-15 Thread R. David Murray
On Fri, 15 Jun 2012 22:48:42 +0200, Victor Stinner wrote: > > 1. Should we keep 'Parameter.implemented' or not.  *Please vote* -1 to implemented. > I still disagree with the deepcopy. I read somewhere that Python > developers are consenting adult. If someone really want to modify a > Signature

Re: [Python-Dev] PEP 362: 4th edition

2012-06-15 Thread Victor Stinner
> 1. Should we keep 'Parameter.implemented' or not.  *Please vote* It looks like only few functions of the os module will use it. Even for the os module, I'm not convinced that it is the appropriate solution to indicate if a feature is supported or not. I would prefer something like os.path.suppor

Re: [Python-Dev] PEP 362: 4th edition

2012-06-15 Thread Alexandre Zani
-1 implemented It appears to target the problem of platform-dependent parameters. However as was discussed previously, much more common than a parameter simply not being supported on a platform is a parameter supporting different values on different platforms. As such, I think that it solves too s

Re: [Python-Dev] PEP 362: 4th edition

2012-06-15 Thread Antoine Pitrou
On Fri, 15 Jun 2012 15:50:25 -0400 Yury Selivanov wrote: > > Open questions: > > 1. Should we keep 'Parameter.implemented' or not. *Please vote* -1 to keeping it. Regards Antoine. ___ Python-Dev mailing list Python-Dev@python.org http://mail.pyth

Re: [Python-Dev] PEP 362: 4th edition

2012-06-15 Thread Larry Hastings
On 06/15/2012 12:50 PM, Yury Selivanov wrote: Open questions: 1. Should we keep 'Parameter.implemented' or not. *Please vote* +1 to keeping Parameter.implemented. Let's get this over with, //arry/ ___ Python-Dev mailing list Python-Dev@python.org

[Python-Dev] PEP 362: 4th edition

2012-06-15 Thread Yury Selivanov
Hello, The new revision of PEP 362 has been posted: http://www.python.org/dev/peps/pep-0362/ Summary: 1. Signature's 'is_args', 'is_kwargs', 'is_keyword_only' were all replaced with a single 'kind' attribute (Nick, I borrowed your description of 'kind' attribute and its possible values.) 2.