Hey folks

I'm finding large sections of Python code that is completely uncommented and 
taking a ton of time to parse thru and figure out exactly what it is doing. I 
realize there are lots of cute little shortcuts one can use in Python to 
implement things, and I'm not trying to discourage their use. However, just 
like in Perl, C, and other languages, you can rapidly turn Python code into a 
dense mess - and that is what I see happening in the Python MTT code.

The solution is to provide detailed comments explaining what the block of code 
is trying to accomplish. So instead of just inserting a block like the 
following:

        for i,t in enumerate(fail_tests):
            for t2 in tests:
                if t2.split("/")[-1] == t:
                    fail_tests[i] = t2


PLEASE explain the code, something like this:

        # the list of tests expected to fail is given by test name, but
        # the list of tests we are to execute has been setup in absolute
        # path form. Thus, scan the two lists and replace the fail_tests
        # entries with their absolute path equivalents. Note that we don't
        # bother removing those we don't match as those won't be executed
        # anyway and thus are irrelevant
        for i,t in enumerate(fail_tests):
            for t2 in tests:
                if t2.split("/")[-1] == t:
                    fail_tests[i] = t2


This was a relatively simple example, but I hope it illustrates the point - 
some of the blocks are really dense and taking 10+ minutes to parse a single 
line and figure out exactly what is being done.

Remember: someone other than you is going to read this code 5+ years from now 
and have to figure out what you did, without benefit of asking you!

Thank you
Ralph


_______________________________________________
mtt-devel mailing list
mtt-devel@lists.open-mpi.org
https://lists.open-mpi.org/mailman/listinfo/mtt-devel

Reply via email to