grok.py (module I found)

Andrew Dalke dalke at acm.org
Wed Aug 1 13:29:44 CEST 2001


Martijn Faassen wrote:
>I've found this module somewhere linked from the Vaults of Parnassus,
>but then my browser crashed and I can't find the link anymore. Did it
>disappear from the vaults?

Sorry about that.  There was some problems with the systems last
night (related to python.org being down) and the code you sent around
had some problems in it that exercised the system flaws.  Things
should be cleared up by now.


>    # try evaluating this code
>    try:
>        exec code
  ...
>    except:
>        # ignore any errors
>        pass

Here's one of the problems.  The code can call sys._exit or
apply_at_time so you'll need to use a TimeBastion.

>    # otherwise, we want to time travel back to the moment in time
>    # just before (one second) we called the function, and try again
>    return timetravel.apply_at_time(grok, [text], {}, call_time - 1)

And this was the real culprit.  That shouldn't be 'call_time - 1'
since you end up with backwards propogating code.  In fact, I didn't
realize there were any Py3K systems running in 2001.  Try using
timetravel.Now() to get a restartable time.  You're working at too
low of a level.  Here's what you should be doing:

  call_time = timetravel.Now()
    ...
  call_time.apply(grok, [text], {})


># o what if the user asks the program to do something impossible, like
>#   a self-contradictory thing? Study temporal mechanics to try to figure
>#   this out. Wouldn't want to hang the universe.
>#

Read the manual.  There's some quantum uncertainty where the backwards
traveling message may randomly become corrupt.  This enables loops
to (eventually) collapse.  Try this:

import timetravel

counter = 0L
queue = timetravel.Queue()
while timetravel.Loop():  # use structured code instead of your jumps
  v = queue.get()
  if v != 1:
    break
  queue.put(1)
  counter += 1
queue.put(0)

print counter


When I run it I usually get numbers around 10E34, which is how much
time it takes for Planck level noise to affect things.

If you don't have the queue.put(0) in then you'll get numbers on the
order of 10E68 since then you need spontaneous message creation
as well as simple corruption, and that's a second order effect.

BTW, how did you manage to post this message?  I thought the PSU
filtered every






More information about the Python-list mailing list