Re: [Python-Dev] The interpreter accepts f(**{'5':'foo'}); is this intentional?

2009-02-05 Thread Scott David Daniels
Christian Heimes wrote: ... The performance penalty is slime to nothing for the common case Sorry, I love this typo. -Scott ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http:

Re: [Python-Dev] The interpreter accepts f(**{'5':'foo'}); is this intentional?

2009-02-05 Thread Christian Heimes
Terry Reedy schrieb: >> The first time a non str object is inserted or looked up, the dict >> swiches to a more general lookup methods. > > This makes adding a string-only dict pretty trivial, if desired. It's not as trivial as it seems. The switch over to the general lookup method happens when a

Re: [Python-Dev] The interpreter accepts f(**{'5':'foo'}); is this intentional?

2009-02-05 Thread Terry Reedy
Christian Heimes wrote: Nick Coghlan wrote: Generally speaking, Python namespace dictionaries (be it globals(), locals(), the __dict__ attribute of an instance or a set of keyword arguments) aren't required to enforce the use of legal identifiers (in many cases, the CPython variants don't even e

Re: [Python-Dev] The interpreter accepts f(**{'5':'foo'}); is this intentional?

2009-02-05 Thread Martin v. Löwis
> How are we going to handle str subclasses and unicode? "Are we going to"? You mean, the current code is not good enough? Why not? > Should we allow > all subclasses of basestring? Or just str and unicode? Or str only? In 2.x, str only, in 3.x, unicode only. Regards, Martin ___

Re: [Python-Dev] The interpreter accepts f(**{'5':'foo'}); is this intentional?

2009-02-05 Thread Christian Heimes
Guido van Rossum schrieb: > I'd prefer a compromise -- the keys should be strings, but should not > be required to be valid identifiers. All Python implementations should > support this. Rationale: a type check is cheap, and using strings > exclusively makes the use of a faster dict implementation

Re: [Python-Dev] The interpreter accepts f(**{'5':'foo'}); is this intentional?

2009-02-05 Thread Christian Heimes
Nick Coghlan wrote: > Generally speaking, Python namespace dictionaries (be it globals(), > locals(), the __dict__ attribute of an instance or a set of keyword > arguments) aren't required to enforce the use of legal identifiers (in > many cases, the CPython variants don't even enforce the use of s

Re: [Python-Dev] The interpreter accepts f(**{'5':'foo'}); is this intentional?

2009-02-05 Thread Guido van Rossum
I'd prefer a compromise -- the keys should be strings, but should not be required to be valid identifiers. All Python implementations should support this. Rationale: a type check is cheap, and using strings exclusively makes the use of a faster dict implementation possible. A check for a conforming

Re: [Python-Dev] The interpreter accepts f(**{'5':'foo'}); is this intentional?

2009-02-05 Thread Nick Coghlan
Michael Haggerty wrote: > Is this behavior required somewhere by the Python language spec, or is > it an error that just doesn't happen to be checked, or is it > intentionally undefined whether this is allowed? Generally speaking, Python namespace dictionaries (be it globals(), locals(), the __dic

Re: [Python-Dev] The interpreter accepts f(**{'5':'foo'}); is this intentional?

2009-02-05 Thread Eric Smith
Calvin Spealman wrote: I would favor this not being constrained. I don't want every use of ** to cause a pattern match to verify each key. I would even be fine without the check for being strings. Define what it should be, but let the implementation be lax. It is no different from any other place

Re: [Python-Dev] The interpreter accepts f(**{'5':'foo'}); is this intentional?

2009-02-05 Thread Calvin Spealman
I would favor this not being constrained. I don't want every use of ** to cause a pattern match to verify each key. I would even be fine without the check for being strings. Define what it should be, but let the implementation be lax. It is no different from any other place where you need to know i

[Python-Dev] The interpreter accepts f(**{'5':'foo'}); is this intentional?

2009-02-05 Thread Michael Haggerty
I can't find documentation about whether there are constraints imposed on the keys in the map passed to a function via **, as in f(**d). According to http://docs.python.org/reference/expressions.html#id9 , d must be a mapping. test_extcall.py implies that the keys of this map must be string