[Python-ideas] Ordered storage of keyword arguments (original) (raw)
M.-A. Lemburg mal at egenix.com
Thu Oct 28 10:13:09 CEST 2010
- Previous message: [Python-ideas] Ordered storage of keyword arguments
- Next message: [Python-ideas] Ordered storage of keyword arguments
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Chris Rose wrote:
I'd like to resurrect a discussion that went on a little over a year ago [1] started by Michael Foord suggesting that it'd be nice if keyword arguments' storage was implemented as an ordered dict as opposed to the current unordered form.
I'm interested in picking this up for implementation, which presumably will require moving the implementation of the existing ordereddict class into the C library. Are there any issues that this might cause in implementation on the py3k development line? [1] http://mail.python.org/pipermail/python-ideas/2009-April/004163.html
Ordered dicts are a lot slower than normal dictionaries. I don't think that we can make such a change unless we want to make Python a lot slower at the same time.
If you only want to learn about the definition order of the keywords you can use the inspect module.
def f(a,b,c=1,d=2): pass ... inspect.getargspec(f) (['a', 'b', 'c', 'd'], None, None, (1, 2))
I don't see much use in having the order of providing the keyword arguments in a function call always available. Perhaps there's a way to have this optionally, i.e. by allowing odicts to be passed in as keyword argument dict ?!
Where I do see a real use is making the order of class attribute and method definition accessible in Python (without having to use meta-class hacks like e.g. Django's ORM does).
It would then be must easier to use classes to represent external resources that rely on order, e.g. database table schemas or XML schemas.
Classes are created using a keyword-like dictionary as well, so the situation is similar. The major difference is that classes aren't created as often as functions are called.
-- Marc-Andre Lemburg eGenix.com
Professional Python Services directly from the Source (#1, Oct 28 2010)
Python/Zope Consulting and Support ... http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
::: Try our new mxODBC.Connect Python Database Interface for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/
- Previous message: [Python-ideas] Ordered storage of keyword arguments
- Next message: [Python-ideas] Ordered storage of keyword arguments
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]