[Python-Dev] New miniconf module (original) (raw)
Sylvain Fourmanoit syfou at users.sourceforge.net
Wed Jul 26 23:43:21 CEST 2006
- Previous message: [Python-Dev] New miniconf module
- Next message: [Python-Dev] New miniconf module
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
It looks like it's trivial to fix; the code uses a strange and unnecessary complication of creating nested classes and nested singleton instances thereof. Getting rid of the singletons to create a new instance for each dump/load call would suffice to make the implementation re-entrant, although de-nesting the classes would also be a good idea. :)
OK then, I will change this.
The loading code could also be made a lot faster by using a dictionary mapping AST node types to functions, instead of doing string manipulation for each node. Each function could take 'pedantic' as a parameter, which would eliminate the need to have an object at all, let alone a singleton. I am not convinced the current string manipulation for mapping the nodes types to the methods of the _Load class has such a significant impact on performance, but I will test your suggestion... The only difference with current code is that we use a dynamically computed string as the dictionary key to locate the function instead of the node type themselves as keys.
Finally, there is an interesting characteristic of the code's interpretation of names: any name other than 'True' is interpreted as 'False'!
;-) It will be corrected in the next release.
On the whole, though, I don't see a lot of difference between this format and say, JavaScript Object Notation (JSON), which can be parsed and generated by many other languages as well as multiple Python libraries already.
The difference is that this is Python code, already familiar to all Python coders... Besides, it sits directly on top of the real Python parser, mitigating the need of a new one, and keeping the added code complexity to a strict minimum.
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.
-- Sylvain <syfou at users.sourceforge.net>
If you think the system is working, ask someone who's waiting for a prompt.
- Previous message: [Python-Dev] New miniconf module
- Next message: [Python-Dev] New miniconf module
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]