Slices time complexity

Chris Angelico rosuav at gmail.com
Tue May 19 14:12:05 EDT 2015


On Wed, May 20, 2015 at 3:46 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> On Wed, 20 May 2015 01:59 am, Marko Rauhamaa wrote:
>
>> Steven D'Aprano <steve+comp.lang.python at pearwood.info>:
>>
>>> To be useful, explanations ought to give the user *predictive power*
>>> -- if I calculate 32767 + 1, what will Python do?
>>>
>>> Explanation #1 predicts that Python will return 32768.
>>> Explanation #2 makes no prediction at all.
>>
>> Any semantic ruleset that correctly predicts the behavior of any given
>> Python program is equally valid.
>
> This is a more reasonable position to take than your earlier stance that the
> only thing that matters is whether it explains observed behaviour. It's
> still wrong, but at least it is defensible in the sense that sometimes a
> ruleset which is objectively wrong but still gives the right answer might
> be *preferred* over one which is objectively correct but hard to
> understand.

Perfect parallel with Magic: The Gathering, where a card may have
reminder text on it which is, in the strictest sense of the
definition, inaccurate, but covers 99%+ of situations without being
horrendously wordy. The fundamental rulebook (the "Comp Rules") goes
into excruciating detail, and is about as readable as the CPython
source code (that is: pretty readable, but too verbose to use as
documentation).

For example, the "First Strike" ability is described simply as "This
creature deals combat damage before creatures without first strike"
[1], but the Comp Rules explain how there are two combat damage steps,
and detail what happens if a creature gains or loses First Strike
during combat.

Even worse, "Madness" is described as "If you discard this card, you
may cast it for its madness cost instead of putting it into your
graveyard" [2]; the Comp Rules divide this into two parts, explaining
in full how the card actually gets from one place to another, where
it's cast from, and so on.

Both of these reminder texts are technically inaccurate, but are
massively preferred over the full text, because they actually fit
inside your brain. Same thing happens with networking; when you go to
https://www.python.org/ in a web browser, your browser establishes an
encrypted connection with the server at www.python.org, and requests
the "/" page. Well, actually, first there are DNS lookups, and IP
routing, and TCP handshakes, and then the whole "establishes an
encrypted connection" bit elides a ton of work involving certificate
checks and so on... but it's much easier to just talk in very high
level terms, even if it's not perfectly accurate. As predictive power
goes, this explanation will adequately tell you what to expect a
request for https://github.com/Rosuav to do; that makes it useful.

An explanation that's more accurate is better than one that's less
accurate; an explanation that's more complicated is worse than one
that's simpler. Somewhere in the middle is an optimal descriptive
style for a given situation.

ChrisA

[1] http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=134753
[2] http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=382849



More information about the Python-list mailing list