[Python-ideas] [Brainstorm] Testing with Documented ABCs

Marcos Eliziario marcos.eliziario at gmail.com
Wed Nov 28 20:22:20 EST 2018


But nobody is talking about exhausting the combinatoric space of all
possible values. Property Based Testing looks like Fuzzy Testing but it is
not quite the same thing.

Property based testing is not about just generating random values till the
heath death of the universe, but generating sensible values in a
configurable way to cover all equivalence classes we can think of. if my
function takes two floating point numbers as arguments, hypothesis
"strategies" won't try all possible combinations of all possible floating
point values, but instead all possible combination of interesting values
(NaN, Infinity, too big, too small, positive, negative, zero, None, decimal
fractions, etc..), something that an experienced programmer probably would
end up doing by himself with a lot of test cases, but that can be better
done with less effort by the automation provided by the hypothesis package.

It could be well that just by using such a tool, a naive programmer could
end up being convinced of the fact that maybe he probably would better be
served by sticking to Decimal Arithmetics :-)




Em qua, 28 de nov de 2018 às 21:43, Antoine Pitrou <antoine at python.org>
escreveu:

>
> But Python integers are variable-sized, and their size is basically
> limited by available memory or address space.
>
> Let's take a typical 64-bit Python build, assuming 4 GB RAM available.
> Let's also assume that 90% of those 4 GB can be readily allocated for
> Python objects (there's overhead, etc.).
>
> Also let's take a look at the Python integer representation:
>
> >>> sys.int_info
> sys.int_info(bits_per_digit=30, sizeof_digit=4)
>
> This means that every 4 bytes of integer object store 30 bit of actual
> integer data.
>
> So, how many bits has the largest allocatable integer on that system,
> assuming 90% of 4 GB are available for allocation?
>
> >>> nbits = (2**32)*0.9*30/4
> >>> nbits
> 28991029248.0
>
> Now how many possible integers are there in that number of bits?
>
> >>> x = 1 << int(nbits)
> >>> x.bit_length()
> 28991029249
>
> (yes, that number was successfully allocated in full.  And the Python
> process occupies 3.7 GB RAM at that point, which validates the estimate.)
>
> Let's try to have a readable approximation of that number.  Convert it
> to a float perhaps?
>
> >>> float(x)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> OverflowError: int too large to convert to float
>
> Well, of course.  So let's just extract a power of 10:
>
> >>> math.log10(x)
> 8727169408.819794
> >>> 10**0.819794
> 6.603801339268099
>
> (yes, math.log10() works on non-float-convertible integers.  I'm
> impressed!)
>
> So the number of representable integers on that system is approximately
> 6.6e8727169408.  Let's hope the Sun takes its time.
>
> (and of course, what is true for ints is true for any variable-sized
> input, such as strings, lists, dicts, sets, etc.)
>
> Regards
>
> Antoine.
>
>
> Le 29/11/2018 à 00:24, David Mertz a écrit :
> > That's easy, Antoine. On a reasonable modern multi-core workstation, I
> > can do 4 billion additions per second. A year is just over 30 million
> > seconds. For 32-bit ints, I can whiz through the task in only 130,000
> > years. We have at least several hundred million years before the sun
> > engulfs us.
> >
> > On Wed, Nov 28, 2018, 5:09 PM Antoine Pitrou <solipsis at pitrou.net
> > <mailto:solipsis at pitrou.net> wrote:
> >
> >     On Wed, 28 Nov 2018 15:58:24 -0600
> >     Abe Dillon <abedillon at gmail.com <mailto:abedillon at gmail.com>> wrote:
> >     > Thirdly, Computers are very good at exhaustively searching
> >     multidimensional
> >     > spaces.
> >
> >     How long do you think it will take your computer to exhaustively
> search
> >     the space of possible input values to a 2-integer addition function?
> >
> >     Do you think it can finish before the Earth gets engulfed by the Sun?
> >
> >     Regards
> >
> >     Antoine.
> >
> >
> >     _______________________________________________
> >     Python-ideas mailing list
> >     Python-ideas at python.org <mailto:Python-ideas at python.org>
> >     https://mail.python.org/mailman/listinfo/python-ideas
> >     Code of Conduct: http://python.org/psf/codeofconduct/
> >
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>


-- 
Marcos Eliziário Santos
mobile/whatsapp/telegram: +55(21) 9-8027-0156
skype: marcos.eliziario at gmail.com
linked-in : https://www.linkedin.com/in/eliziario/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20181128/85bf3149/attachment.html>


More information about the Python-ideas mailing list