[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87ecnhso15.fsf@yellow.woof>
Date: Thu, 22 Jan 2026 15:46:46 +0100
From: Nam Cao <namcao@...utronix.de>
To: Wander Lairson Costa <wander@...hat.com>, Steven Rostedt
<rostedt@...dmis.org>, Gabriele Monaco <gmonaco@...hat.com>, Wander
Lairson Costa <wander@...hat.com>, open list
<linux-kernel@...r.kernel.org>, "open list:RUNTIME VERIFICATION (RV)"
<linux-trace-kernel@...r.kernel.org>
Subject: Re: [PATCH 04/26] rv/rvgen: replace __len__() calls with len()
Wander Lairson Costa <wander@...hat.com> writes:
> Replace all direct calls to the __len__() dunder method with the
> idiomatic len() built-in function across the rvgen codebase. This
> change eliminates a Python anti-pattern where dunder methods are
> called directly instead of using their corresponding built-in
> functions.
>
> The changes affect nine instances across two files. In automata.py,
> the empty string check is further improved by using truthiness
> testing instead of explicit length comparison. In dot2c.py, all
> length checks in the get_minimun_type, __get_max_strlen_of_states,
> and get_aut_init_function methods now use the standard len()
> function. Additionally, spacing around keyword arguments has been
> corrected to follow PEP 8 guidelines.
>
> Direct calls to dunder methods like __len__() are discouraged in
> Python because they bypass the language's abstraction layer and
> reduce code readability. Using len() provides the same functionality
> while adhering to Python community standards and making the code more
> familiar to Python developers.
>
> Signed-off-by: Wander Lairson Costa <wander@...hat.com>
Reviewed-by: Nam Cao <namcao@...utronix.de>
Powered by blists - more mailing lists