Looping [was Re: Python and the need for speed]
bc at freeuk.com
Sun Apr 16 19:22:35 EDT 2017
On 16/04/2017 19:42, Chris Angelico wrote:
> On Mon, Apr 17, 2017 at 4:21 AM, bartc <bc at freeuk.com> wrote:
>> Here is a function from some old CPython source that appears to be something
>> to do with While statements:
>> static int
>> validate_while(node *tree)
>> Look, no comments! Are you going to castigate the developers of CPython for
>> that? (I guess not.)
> Can you find the equivalent in the current sources? I think it might be here:
> while_stmt: 'while' test ':' suite ['else' ':' suite]
> A single, extremely readable line. Abstract, not concrete.
How do you know my code fragment wasn't also generated? Since it was
parsing C, the refs for that language also define the while statement
'while' '(' expression ')' statement
but actually it was done manually. It's part of a suite of functions
that do things in a common pattern, and would be documented as a set
rather than line by line. And elsewhere calls to such a function would
also be part of a chain of tests.
That's if I needed to documented it (but I can't remember how many
parsers I've done along the same lines since c.1979).
But I've glanced through the CPython code again, and it is quite lightly
commented. Although sometimes it gets quite chatty.
> Want to show me your source for this source?
The source files I looked at were dated around 2010. I've no idea where
they came from. I think I'd wanted to compile it, but unfortunately,
they're not written in C, but a combination of C, make-file,
compiler-options, and bash-script with a bunch of Linux dependencies.
> Next complaint, please.
No complaint, just saying other projects are sparse on comments too. And
my code isn't intended as open source.
More information about the Python-list