qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 09/11] qapi/introspect.py: create a typed 'Annotated' data


From: John Snow
Subject: Re: [PATCH v2 09/11] qapi/introspect.py: create a typed 'Annotated' data strutcure
Date: Wed, 16 Dec 2020 20:30:11 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1

On 12/16/20 2:08 AM, Markus Armbruster wrote:
We all have our phobias. I find "isinstance(x,
extremely_common_stdlib_type)" to be extremely fragile and likely to
frustrate.
You're applying programming-in-the-large reasoning to a
programming-in-the-small case.


"Surely, they won't use my proof of concept code in production!"

Ah, alas, ...

Say you're writing a piece of code you expect to be used in contexts you
prudently refuse to predict.  The code deals with a bunch of basic
Python types.  Reserving another basic Python type for internal use may
well be unwise then, because it can make your code break confusingly
when this other type appears in input.  Which it shouldn't, but making
your reusable code harder to misuse, and misuses easier to diagnose are
laudable goals.

This is not such a piece of code.  All the users it will ever have are
in the same file of 200-something LOC.


I'm just saying that this type of code has bitten me in the ass before. You're right that it's not likely to bite someone explicitly here, but that's indeed why it came in the "Also, ..." section.

I've reworked the commit message a bit by now, but I suspect you'll still want to take the red marker to it a bit.

--js




reply via email to

[Prev in Thread] Current Thread [Next in Thread]