Martin, Thanks for pointing this out. I might have found that code eventualy but it would have taken me quite sometime.
There was a request from a user to make ordereddict more of drop-in replacement for dict. That can be already be done by specifying the relax keyword parameter (or defining a subclass that does so), but it made me revisit the idea of investigating the keyword parameter order.. I will just drop this idea Thanks Anthon On Nov 18, 12:08 pm, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > I am not sure if this kind of info is available internally to the > > interpreter (ordereddict is in C, so I would even prefer that). Has > > anyone done this or anything like it? > > It's not available. See ceval.c:do_call; this fills the dictionary. > From then on, information about the order of keyword arguments is > lost. > > > I could probably compile the python interpreter to use ordereddict > > instead of dict and then the parser would insert the keyword > > parameters in specification order in the **kw ordereddict, after which > > iteration over parameters would be ordered. > > If you'ld do that literally, you'll find that the keyword arguments are > in reverse order. > > > As an aside: I think that allowing dict to be initialised from keyword > > parameters (introduced in Python 2.2 IIRC) was a mistake. This kind of > > use of keyword parameters prevents any real keyword parameters. E.g. > > with 'maxsize' that restricts the dictionary size or 'unique' that > > would throw an Exception if an existing key gets reassigned. > > For your own dictionary implementation, you are not required to follow > this interface - in particular if you believe it was a mistake. > > Regards, > Martin -- http://mail.python.org/mailman/listinfo/python-list