[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v6 01/19] qapi: Replace List[str] with Sequence[str] for ifco
From: |
Markus Armbruster |
Subject: |
Re: [PATCH v6 01/19] qapi: Replace List[str] with Sequence[str] for ifcond |
Date: |
Tue, 16 Feb 2021 16:58:02 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
John Snow <jsnow@redhat.com> writes:
> On 2/16/21 3:43 AM, Markus Armbruster wrote:
>> John Snow <jsnow@redhat.com> writes:
>>
>>> It does happen to be a list (as of now), but we can describe it in more
>>> general terms with no loss in accuracy to allow tuples and other
>>> constructs.
>>>
>>> In the future, we can write "ifcond: Sequence[str] = ()" as a default
>>> parameter, which we could not do with a Mutable type like a List.
>> Well, we could write "= []", but we shouldn't. Worth a commit
>> message
>> tweak?
>>
>
> It would be funny to leave it in to see if anyone tries to disprove
> me, and in the act of disproving me, learns for themselves why you
> "can't" do that. Rite of passage for Python programming.
>
> Jokes aside:
>
> "which we could not do ^safely^ with a Mutable type like a List."
Works for me.
> If that warrants further exposition by Professor Snow:
>
> "(Unsafe due to how Python initializes defaults, see
> https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments)"
I can add that if you prefer.
> I leave it to your discretion.
>
>>> Signed-off-by: John Snow <jsnow@redhat.com>
>> Reviewed-by: Markus Armbruster <armbru@redhat.com>
>>
>
> These are worth more than BTC!
;)
- [PATCH v6 00/19] qapi: static typing conversion, pt2, John Snow, 2021/02/15
- [PATCH v6 03/19] qapi/introspect.py: use _make_tree for features nodes, John Snow, 2021/02/15
- [PATCH v6 06/19] qapi/introspect.py: Unify return type of _make_tree(), John Snow, 2021/02/15
- [PATCH v6 08/19] qapi/introspect.py: Always define all 'extra' dict keys, John Snow, 2021/02/15
- [PATCH v6 05/19] qapi/introspect.py: guard against ifcond/comment misuse, John Snow, 2021/02/15
- [PATCH v6 09/19] qapi/introspect.py: Introduce preliminary tree typing, John Snow, 2021/02/15
- [PATCH v6 13/19] qapi/introspect.py: remove _gen_variants helper, John Snow, 2021/02/15
- [PATCH v6 04/19] qapi/introspect.py: add _gen_features helper, John Snow, 2021/02/15
- [PATCH v6 12/19] qapi/introspect.py: improve readability of _tree_to_qlit, John Snow, 2021/02/15
- [PATCH v6 11/19] qapi/introspect.py: improve _tree_to_qlit error message, John Snow, 2021/02/15