[Python-Dev] New miniconf module

Sylvain Fourmanoit syfou at users.sourceforge.net
Thu Jul 27 09:39:39 CEST 2006


An updated version is now available, based to the feedback of Phillip J. 
Eby and David Hopwood (stand-alone module[1], patch[2]):

- the module is now reentrant
- the sloppy case with Name nodes is now covered properly
- the node lookup procedure was optimized, leading to a 20% speed 
increase on the average case... Phillip, I was wrong to doubt you. ;-) 
There is undoubtedly still room from improvement, but that's a good start.

>> But I agree this looks a lot like JSON, since ecmascript syntax for
>> literals looks a lot like the one of Python... For the same reasons there
>> is a need for JSON, I think having something like miniconf in the
>> standard lib would benefit the users.
>
> Actually, I would see more reason to include JSON in the standard library, 
> since it's at least something approaching an internet protocol these days.

Having JSON there would indeed be nice: In fact, I recall being initially 
surprised it was not supported by the standard library.

But is there a need to choose? Why not have both? The miniconf approach 
has its advantages and differences:

- The code is short and simple. Since all the real work is performed by 
the Python parser, very little has to be done on top of that: it should be 
easy to maintain, and will benefit of all the future work (patches, etc.) 
that will be integrated to it in the future.

- The source it works on is valid Python source, which seems to be a plus 
for a dynamic, reflexive language such as Python... Things such as this 
will work:

>>> from miniconf import dump
>>> file('test.py','w').write(dump({'spam': 1}))
>>> import test

I know this in not the best example, but you get the idea...

- Unlike JSON, miniconf is not introducing any new notation or syntax at 
all: it uses a strict, well defined subset of the Python grammar that 
every Python user is already familiar with; it is in no way a 
data-interchange format, but it feels pretty natural in a all-python 
environment... In that sense, it is well documented and standardized.

- Am I missing something, or is JSON not supporting comments inside the 
parse tree? That's not really convenient for storage of configuration 
information.

Anyway, if I had to choose between the two, I would definitively want 
simplejson part of the standard library well before miniconf, since it can 
be used in so many different situations, but I wouldn't 
choose JSON as a configuration format given the choice to use the Python 
notation employed by miniconf either.

Yours,

-- 
Sylvain <syfou at users.sourceforge.net>

Nobody said computers were going to be polite.

[1]http://cheeseshop.python.org/pypi?:action=display&name=miniconf&version=1.1.0
[2]http://sourceforge.net/tracker/index.php?func=detail&aid=1527597&group_id=5470&atid=355470


More information about the Python-Dev mailing list