[Python-ideas] PEP 426, YAML in the stdlib and implementation discovery

Brett Cannon brett at python.org
Fri May 31 22:11:10 CEST 2013


On Fri, May 31, 2013 at 2:43 PM, Guido van Rossum <guido at python.org> wrote:
> On Fri, May 31, 2013 at 11:35 AM, Brett Cannon <brett at python.org> wrote:
>> So yaml is not going to end up in the stdlib. The format is not used
>> widely enough to warrant being added nor have to maintain a parser for
>> such a complicated format.
>
> Hm. What makes you think it's not being used widely enough?

In my purview it isn't. I mean I know App Engine uses it but I just
don't come across it often enough to think that we should incorporate
it. Heck, I think I may have suggested it years back when I came
across a need, but at this moment in time I just don't have a feeling
it's wide enough to want to maintain the code.

> I suppose
> JSON is more popular, but it's not like YAML is dying. AFAIK there's a
> 3rd party yaml parser that we could incorporate with its authors'
> permission -- this would save people from a pretty common dependency
> (just like we did for JSON).

Sure, but the pure Python version is naively 5,500 lines, just 500
lines less than decimal.py. The json package is 1,100. Sure it's
difficult to get right since the format is hard to parse which is an
argument for it's addition, but this would not be a small import of
code. And the popularity:code size/complexity just isn't an easy sell
to me. Obviously it's just a gut feeling but I just am not feeling it
as worth the hassle.

But we really won't know w/o asking python-dev about this.

>
>>> Is there a reason JSON is used other than YAML not being in the stdlib?
>>
>> It's simpler, it's Python syntax, it's faster to parse.
>
> I would warn strongly against the "JSON is Python syntax" meme. While
> you can usually read JSON with Python's eval(), *writing* it with
> repr() is a disaster because of JSON's requirement to use double
> string quotes. And as we know, eval() is unsafe, so the conclusion is
> that one should always use the json module, and never rely on the fact
> that it looks like Python (except that it makes the format easy to
> understand to humans familiar with Python).

I'm talking purely from the perspective of writing it by hand which is
what sparked this conversation. There is no new format to really learn
like with YAML: write a Python dict using double-quotes for strings
and lowercase your singletons from Python and you basically there.

-Brett

>
> (I have no opinion on the use of YAML for metadata.)
>
> --
> --Guido van Rossum (python.org/~guido)


More information about the Python-ideas mailing list