PyYaml?

Chris S. chrisks at NOSPAM.udel.edu
Wed Sep 22 22:38:45 CEST 2004


Istvan Albert wrote:

> IMHO you are already too focused on some specific use cases (invoices etc)
> and you'll do probably better if you'd move your entire effort
> to that direction.
> 
> What you are proposing, whitespace as a markup is not nearly as readable
> as XML when the dependancy tree gets more complicated. Just because
> whitespace indentation work for programming it does not mean
> it works for data too.

XML was designed as a general purpose method of data description, and so 
suffers from the requirement of having to explicitly tag everything and 
define the meaning of each of these tags. This introduces tremendous 
inefficiency, especially with large, yet even small data structures. For 
an example, data={'abc':[1,2,3]} (20 bytes), takes 38 bytes to store 
with YAML, 41 bytes to store with Pickle, and 416 bytes to store with 
XML (using xml_pickle module by David Mertz). I'd agree that readability 
is hindered by complex dependencies, but XML's overly verbose syntax is 
unreadable for even simple data IMHO. I've yet to find a situation where 
any supposedly readable format doesn't benefit from whitespace 
indentation or simplistic notation, two aspects YAML enjoys.

data={'abc':[1,2,3]}

---
abc:
     - 1
     - 2
     - 3

(dp1
S'abc'
p2
(lp3
I1
aI2
aI3
as.

<?xml version="1.0"?>
<!DOCTYPE PyObject SYSTEM "PyObjects.dtd">
<PyObject class="XML_Pickler" id="12405096">
<attr name="stuff" type="dict" id="13060256">
   <entry>
     <key type="string" value="abc" />
     <val type="list" id="12976528">
       <item type="numeric" value="1" />
       <item type="numeric" value="2" />
       <item type="numeric" value="3" />
     </val>
   </entry>
</attr>
</PyObject>



More information about the Python-list mailing list