are elements of a list in sequence in list b

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Sat Feb 9 14:58:40 EST 2008


Steven D'Aprano:
> I believe that it is considered an abuse of doctest to write a function
> with 28 lines of code and 19 tests

I agree with you. Most of my functions/methods have more compact
doctests (putting things on many lines has the advantage of letting
you locate the failing tests in a simpler way).


> In my opinion, that *doc* test is
> redundant (it shows nothing the reader hasn't
> already seen), and should be a unit test.

Doctests are simpler and faster to use for me, and they have the
advantage of keeping tests close to the tested things, instead of
scattering things in two or more places.
Generally between the choice of less tests or more doctests, I prefer
more doctests. If you have infinite time you don't need to take such
choices.


>     ... on Windows, clock() has microsecond granularity but time()'s
>     granularity is 1/60th of a second; on Unix, clock() has 1/100th
>     of a second granularity and time() is much more precise.

I did know this... Maybe the a single function can be put there, fit
for everyone.


> An easy way to do that is by importing timeit.default_timer.

I didn't know about this, thank you. I think the timeit docs don't
show that function well enough, I can't find it in a quick search. And
that name is quite long to write, so maybe a shorter name is better
(like "timer").

Bye and thank you,
bearophile



More information about the Python-list mailing list