Commits

Philip Jenvey  committed 8b3bc6b Merge

merge default

  • Participants
  • Parent commits ca88ab7, 97f0ffc
  • Branches py3k

Comments (0)

Files changed (123)

File demo/autopath.py

-import sys, os
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

File demo/bpnn.py

-#!/usr/bin/env python
-"""
-    Translator Demo
-
-    To analyse and type-annotate the functions and class defined in
-    this module, starting from the entry point function demo(),
-    use the following command line:
-
-        ../pypy/translator/goal/translate.py bpnn.py
-
-    Insert '--help' before 'bpnn.py' for a list of translation options,
-    or see the Overview of Command Line Options for translation at
-    http://codespeak.net/pypy/dist/pypy/doc/config/commandline.html
-"""
-# Back-Propagation Neural Networks
-# 
-# Written in Python.  See http://www.python.org/
-#
-# Neil Schemenauer <nascheme@enme.ucalgary.ca>
-#
-# Modifications to the original (Armin Rigo):
-#   * import random from PyPy's lib, which is Python 2.2's plain
-#     Python implementation
-#   * print a doc about how to start the Translator
-
-import sys
-import math
-import time
-
-import autopath
-from pypy.rlib import rrandom
-
-PRINT_IT = True
-
-random = rrandom.Random(1)
-
-# calculate a random number where:  a <= rand < b
-def rand(a, b):
-    return (b-a)*random.random() + a
-
-# Make a matrix (we could use NumPy to speed this up)
-def makeMatrix(I, J, fill=0.0):
-    m = []
-    for i in range(I):
-        m.append([fill]*J)
-    return m
-
-class NN:
-    
-    def __init__(self, ni, nh, no):
-        # number of input, hidden, and output nodes
-        self.ni = ni + 1 # +1 for bias node
-        self.nh = nh
-        self.no = no
-
-        # activations for nodes
-        self.ai = [1.0]*self.ni
-        self.ah = [1.0]*self.nh
-        self.ao = [1.0]*self.no
-        
-        # create weights
-        self.wi = makeMatrix(self.ni, self.nh)
-        self.wo = makeMatrix(self.nh, self.no)
-        # set them to random vaules
-        for i in range(self.ni):
-            for j in range(self.nh):
-                self.wi[i][j] = rand(-2.0, 2.0)
-        for j in range(self.nh):
-            for k in range(self.no):
-                self.wo[j][k] = rand(-2.0, 2.0)
-
-        # last change in weights for momentum   
-        self.ci = makeMatrix(self.ni, self.nh)
-        self.co = makeMatrix(self.nh, self.no)
-
-    def update(self, inputs):
-        if len(inputs) != self.ni-1:
-            raise ValueError, 'wrong number of inputs'
-
-        # input activations
-        for i in range(self.ni-1):
-            #self.ai[i] = 1.0/(1.0+math.exp(-inputs[i]))
-            self.ai[i] = inputs[i]
-
-        # hidden activations
-        for j in range(self.nh):
-            sum = 0.0
-            for i in range(self.ni):
-                sum = sum + self.ai[i] * self.wi[i][j]
-            self.ah[j] = 1.0/(1.0+math.exp(-sum))
-
-        # output activations
-        for k in range(self.no):
-            sum = 0.0
-            for j in range(self.nh):
-                sum = sum + self.ah[j] * self.wo[j][k]
-            self.ao[k] = 1.0/(1.0+math.exp(-sum))
-
-        return self.ao[:]
-
-
-    def backPropagate(self, targets, N, M):
-        if len(targets) != self.no:
-            raise ValueError, 'wrong number of target values'
-
-        # calculate error terms for output
-        output_deltas = [0.0] * self.no
-        for k in range(self.no):
-            ao = self.ao[k]
-            output_deltas[k] = ao*(1-ao)*(targets[k]-ao)
-
-        # calculate error terms for hidden
-        hidden_deltas = [0.0] * self.nh
-        for j in range(self.nh):
-            sum = 0.0
-            for k in range(self.no):
-                sum = sum + output_deltas[k]*self.wo[j][k]
-            hidden_deltas[j] = self.ah[j]*(1-self.ah[j])*sum
-
-        # update output weights
-        for j in range(self.nh):
-            for k in range(self.no):
-                change = output_deltas[k]*self.ah[j]
-                self.wo[j][k] = self.wo[j][k] + N*change + M*self.co[j][k]
-                self.co[j][k] = change
-                #print N*change, M*self.co[j][k]
-
-        # update input weights
-        for i in range(self.ni):
-            for j in range(self.nh):
-                change = hidden_deltas[j]*self.ai[i]
-                self.wi[i][j] = self.wi[i][j] + N*change + M*self.ci[i][j]
-                self.ci[i][j] = change
-
-        # calculate error
-        error = 0.0
-        for k in range(len(targets)):
-            delta = targets[k]-self.ao[k]
-            error = error + 0.5*delta*delta
-        return error
-
-
-    def test(self, patterns):
-        for p in patterns:
-            if PRINT_IT:
-                print p[0], '->', self.update(p[0])
-
-    def weights(self):
-        if PRINT_IT:
-            print 'Input weights:'
-            for i in range(self.ni):
-                print self.wi[i]
-            print
-            print 'Output weights:'
-            for j in range(self.nh):
-                print self.wo[j]
-
-    def train(self, patterns, iterations=2000, N=0.5, M=0.1):
-        # N: learning rate
-        # M: momentum factor
-        for i in xrange(iterations):
-            error = 0.0
-            for p in patterns:
-                inputs = p[0]
-                targets = p[1]
-                self.update(inputs)
-                error = error + self.backPropagate(targets, N, M)
-            if PRINT_IT and i % 100 == 0:
-                print 'error', error
-
-
-def demo():
-    # Teach network XOR function
-    pat = [
-        [[0,0], [0]],
-        [[0,1], [1]],
-        [[1,0], [1]],
-        [[1,1], [0]]
-    ]
-
-    # create a network with two input, two hidden, and two output nodes
-    n = NN(2, 3, 1)
-    # train it with some patterns
-    n.train(pat, 2000)
-    # test it
-    n.test(pat)
-
-
-# __________  Entry point for stand-alone builds __________
-
-import time
-
-def entry_point(argv):
-    if len(argv) > 1:
-        N = int(argv[1])
-    else:
-        N = 200
-    T = time.time()
-    for i in range(N):
-        demo()
-    t1 = time.time() - T
-    print "%d iterations, %s milliseconds per iteration" % (N, 1000.0*t1/N)
-    return 0
-
-# _____ Define and setup target ___
-
-def target(*args):
-    return entry_point, None
-
-if __name__ == '__main__':
-    if len(sys.argv) == 1:
-        sys.argv.append('1')
-    entry_point(sys.argv)
-    print __doc__

File demo/dis-goal.py

-"""
-An old-time classical example, and one of our first goals.
-To run on top of PyPy.
-"""
-
-import dis
-dis.dis(dis.dis)

File demo/distribution/client.py

-""" This a sample client, suitable for use with server.py from this
-directory
-
-run by:
-pypy-c client.py
-"""
-
-HOST = '127.0.0.1'
-PORT = 12222
-
-from distributed.socklayer import connect
-remote_handle = connect((HOST, PORT))
-
-import code
-code.interact(local=locals())
-
-""" Things that can be done: 1. remote object access
-
-x = remote_handle.x
-assert type(x) is remote_handle.X # typecheck
-x.meth(lambda x: x + 10, 6) # remote call, with callback localy
-x.meth(remote_handle.f, 3) # remote call, remote callback
-remote_handle.sys._getframe(2).f_locals['x'] # remote frame access
-# XXX should be 'is x' and shouldn't need (2) argument
-
-# XXX next one does not work, while it should. Too much mangling with remote
-# traceback frames probably
-try:
-  x.meth(1, 2) # non-callable argument, AssertionError
-except:
-  import sys
-  e, c, tb = sys.exc_info()
-  import pdb
-  pdb.post_mortem(tb)
-"""

File demo/distribution/fileclient.py

-
-""" This is sample client for a server based in fileserver.py, not counting
-initialization, code.interact and __doc__ has just 2 lines! Usage:
-
-pypy-c fileclient.py
-
-The file_opener is a proxy for remote file object. Which means you can
-perform same operations as locally, like file_opener('/etc/passwd').read()
-or file_opener('/tmp/x', 'w').write('x')
-
-pypy-c needs to be compiled with --allworkingmodules in order to have socket
-working.
-"""
-
-HOST = '127.0.0.1'
-PORT = 12221
-
-from distributed.socklayer import connect
-file_opener = connect((HOST, PORT)).open
-
-import code
-code.interact(local=locals())
-# The file_opener is a proxy for remote file object. Which means you can
-# perform same operations as locally, like file_opener('/etc/passwd').read()
-# or file_opener('/tmp/x', 'w').write('x')

File demo/distribution/fileserver.py

-""" This is a sample demo showcasing file server, done by the pypy
-distribution library.
-
-Not counting __doc__ and initialization this is 2 line,
-fully operational file server,
-sample client which is in fileclient.py is included as well.
-
-run by:
-pypy-c fileserver.py
-
-pypy-c needs to be compiled with --allworkingmodules in order to have socket
-working.
-"""
-
-HOST = '127.0.0.1' # defaults to localhost, not to export your files
-PORT = 12221
-
-from distributed.socklayer import socket_loop
-socket_loop((HOST, PORT), {'open':open})

File demo/distribution/server.py

-""" This is a demo exposing all globals from the current process over
-socket, to be accessible remotely.
-
-run by:
-pypy-c server.py
-
-pypy-c needs to be compiled with --allworkingmodules in order to have socket
-working.
-"""
-
-# things to export
-# function
-def f(x):
-    return x + 3
-
-# class
-class X:
-    def __init__(self):
-        self.slot = 3
-    
-    def meth(self, f, arg):
-        """ Method eating callable and calling it with an argument
-        """
-        assert callable(f)
-        return f(arg)
-
-# object
-x = X()
-
-# module
-import sys
-
-# constants
-HOST = '127.0.0.1'
-PORT = 12222
-
-from distributed.socklayer import socket_loop
-socket_loop((HOST, PORT), globals())

File demo/fibonacci.py

-"""
-Thunk (a.k.a. lazy objects) in PyPy.
-To run on top of the thunk object space with the following command-line:
-
-    py.py -o thunk fibonacci.py
-
-This is a typical Functional Programming Languages demo, computing the
-Fibonacci sequence by using an infinite lazy linked list.
-"""
-
-try:
-    from __pypy__ import thunk    # only available in 'py.py -o thunk'
-except ImportError:
-    print __doc__
-    raise SystemExit(2)
-
-# ____________________________________________________________
-
-
-class ListNode:
-    def __init__(self, head, tail):
-        self.head = head   # the first element of the list
-        self.tail = tail   # the sublist of all remaining elements
-
-
-def add_lists(list1, list2):
-    """Compute the linked-list equivalent of the Python expression
-          [a+b for (a,b) in zip(list1,list2)]
-    """
-    return ListNode(list1.head + list2.head,
-                    thunk(add_lists, list1.tail, list2.tail))
-
-
-# 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
-Fibonacci = ListNode(1, ListNode(1, None))
-Fibonacci.tail.tail = thunk(add_lists, Fibonacci, Fibonacci.tail)
-
-
-if __name__ == '__main__':
-    node = Fibonacci
-    while True:
-        print node.head
-        node = node.tail

File demo/fibonacci2.py

-"""
-Lazy functions in PyPy.
-To run on top of the thunk object space with the following command-line:
-
-    py.py -o thunk fibonacci2.py
-
-This is a typical Functional Programming Languages demo, computing the
-Fibonacci sequence as nested 2-tuples.
-"""
-
-import pprint
-
-try:
-    from __pypy__ import lazy
-except ImportError:
-    print __doc__
-    raise SystemExit(2)
-
-
-@lazy
-def fibo(a, b):
-    return (a, fibo(b, a + b))
-
-
-fibonacci = fibo(1, 1)
-
-pprint.pprint(fibonacci, depth=10)

File demo/foodbill.py

-"""
-Of historical interest: we computed the food bill of our first Gothenburg
-sprint with PyPy :-)
-"""
-
-slips=[(1, 'Kals MatMarkn', 6150, 'Chutney for Curry', 'dinner Saturday'),
-       (2, 'Kals MatMarkn', 32000, 'Spaghetti, Beer', 'dinner Monday'),
-       (2, 'Kals MatMarkn', -810, 'Deposit on Beer Bottles', 'various'),
-       (3, 'Fram', 7700, 'Rice and Curry Spice', 'dinner Saturday'),
-       (4, 'Kals MatMarkn', 25000, 'Alcohol-Free Beer, sundries', 'various'),
-       (4, 'Kals MatMarkn', -1570, "Michael's toothpaste", 'none'),
-       (4, 'Kals MatMarkn', -1690, "Laura's toothpaste", 'none'),
-       (4, 'Kals MatMarkn', -720, 'Deposit on Beer Bottles', 'various'),
-       (4, 'Kals MatMarkn', -60, 'Deposit on another Beer Bottle', 'various'),
-       (5, 'Kals MatMarkn', 26750, 'lunch bread meat cheese', 'lunch Monday'),
-       (6, 'Kals MatMarkn', 15950, 'various', 'dinner Tuesday and Thursday'),
-       (7, 'Kals MatMarkn', 3650, 'Drottningsylt, etc.', 'dinner Thursday'),
-       (8, 'Kals MatMarkn', 26150, 'Chicken and Mushroom Sauce', 'dinner Wed'),
-       (8, 'Kals MatMarkn', -2490, 'Jacob and Laura -- juice', 'dinner Wed'),
-       (8, 'Kals MatMarkn', -2990, "Chicken we didn't cook", 'dinner Wednesday'),
-       (9, 'Kals MatMarkn', 1380, 'fruit for Curry', 'dinner Saturday'),
-       (9, 'Kals MatMarkn', 1380, 'fruit for Curry', 'dinner Saturday'),
-       (10, 'Kals MatMarkn', 26900, 'Jansons Frestelse', 'dinner Sunday'),
-       (10, 'Kals MatMarkn', -540, 'Deposit on Beer Bottles', 'dinner Sunday'),
-       (11, 'Kals MatMarkn', 22650, 'lunch bread meat cheese', 'lunch Thursday'),
-       (11, 'Kals MatMarkn', -2190, 'Jacob and Laura -- juice', 'lunch Thursday'),
-       (11, 'Kals MatMarkn', -2790, 'Jacob and Laura -- cereal', 'lunch Thurs'),
-       (11, 'Kals MatMarkn', -760, 'Jacob and Laura -- milk', 'lunch Thursday'),
-       (12, 'Kals MatMarkn', 18850, 'lunch bread meat cheese', 'lunch Friday'),
-       (13, 'Kals MatMarkn', 18850, 'lunch bread meat cheese', 'guestimate Sun'),
-       (14, 'Kals MatMarkn', 18850, 'lunch bread meat cheese', 'guestimate Tues'),
-       (15, 'Kals MatMarkn', 20000, 'lunch bread meat cheese', 'guestimate Wed'),
-       (16, 'Kals MatMarkn', 42050, 'grillfest', 'dinner Friday'),
-       (16, 'Kals MatMarkn', -1350, 'Deposit on Beer Bottles', 'dinner Friday'),
-       (17, 'System Bolaget', 15500, 'Cederlunds Caloric', 'dinner Thursday'),
-       (17, 'System Bolaget', 22400, '4 x Farnese Sangiovese 56SEK', 'various'),
-       (17, 'System Bolaget', 22400, '4 x Farnese Sangiovese 56SEK', 'various'),
-       (17, 'System Bolaget', 13800, '2 x Jacobs Creek 69SEK', 'various'),
-       (18, 'J and Ls winecabinet', 10800, '2 x Parrotes 54SEK', 'various'),
-       (18, 'J and Ls winecabinet', 14700, '3 x Saint Paulin 49SEK', 'various'),
-       (18, 'J and Ls winecabinet', 10400, '2 x Farnese Sangioves 52SEK',
-        'cheaper when we bought it'),
-       (18, 'J and Ls winecabinet', 17800, '2 x Le Poiane 89SEK', 'various'),
-       (18, 'J and Ls winecabinet', 9800, '2 x Something Else 49SEK', 'various'),
-       (19, 'Konsum', 26000, 'Saturday Bread and Fruit', 'Slip MISSING'),
-       (20, 'Konsum', 15245, 'Mooseburgers', 'found slip'),
-       (21, 'Kals MatMarkn', 20650, 'Grilling', 'Friday dinner'),
-       (22, 'J and Ls freezer', 21000, 'Meat for Curry, grilling', ''),
-       (22, 'J and Ls cupboard', 3000, 'Rice', ''),
-       (22, 'J and Ls cupboard', 4000, 'Charcoal', ''),
-       (23, 'Fram', 2975, 'Potatoes', '3.5 kg @ 8.50SEK'),
-       (23, 'Fram', 1421, 'Peas', 'Thursday dinner'),
-       (24, 'Kals MatMarkn', 20650, 'Grilling', 'Friday dinner'),
-       (24, 'Kals MatMarkn', -2990, 'TP', 'None'),
-       (24, 'Kals MatMarkn', -2320, 'T-Gul', 'None')
-       ]
- 
-print [t[2] for t in slips]
-print (reduce(lambda x, y: x+y, [t[2] for t in slips], 0))/900

File demo/pickle_coroutine.py

-"""
-Stackless demo.
-
-This example only works on top of a pypy-c compiled with stackless features
-and the signal module:
-
-    translate.py --stackless targetpypystandalone --withmod-signal
-
-Usage:
-
-    pypy-c pickle_coroutine.py --start demo.pickle
-
-        Start the computation.  You can interrupt it at any time by
-        pressing Ctrl-C; at this point, the state of the computing
-        coroutine is saved in demo.pickle.
-
-    pypy-c pickle_coroutine.py --resume demo.pickle
-
-        Reload the coroutine from demo.pickle and continue running it.
-        (It can be interrupted again with Ctrl-C.)
-
-This demo is documented in detail in pypy/doc/stackless.txt.
-"""
-
-try:
-    import sys, pickle, signal
-    from stackless import coroutine
-except ImportError:
-    print __doc__
-    sys.exit(2)
-
-
-def ackermann(x, y):
-    check()
-    if x == 0:
-        return y + 1
-    if y == 0:
-        return ackermann(x - 1, 1)
-    return ackermann(x - 1, ackermann(x, y - 1))
-
-# ____________________________________________________________
-
-main = coroutine.getcurrent()
-sys.setrecursionlimit(100000)
-
-interrupt_flag = False
-
-def interrupt_handler(*args):
-    global interrupt_flag
-    interrupt_flag = True
-
-def check():
-    if interrupt_flag:
-        main.switch()
-
-
-def execute(coro):
-    signal.signal(signal.SIGINT, interrupt_handler)
-    res = coro.switch()
-    if res is None and coro.is_alive:    # interrupted!
-        print "interrupted! writing %s..." % (filename,)
-        f = open(filename, 'w')
-        pickle.dump(coro, f)
-        f.close()
-        print "done"
-    else:
-        print "result:", res
-
-try:
-    operation, filename = sys.argv[1:]
-except ValueError:
-    print __doc__
-    sys.exit(2)
-
-if operation == '--start':
-    coro = coroutine()
-    coro.bind(ackermann, 3, 7)
-    print "running from the start..."
-    execute(coro)
-elif operation == '--resume':
-    print "reloading %s..." % (filename,)
-    f = open(filename)
-    coro = pickle.load(f)
-    f.close()
-    print "done, running now..."
-    execute(coro)

File demo/sharedref.py

-"""
-   This is an example usage of the 'thunk' object space of PyPy.
-   It implements transparent distributed object manipulation.
-
-   Start a server on a local port, say port 8888, with:
-
-       $ py.py -o thunk sharedref.py 8888
-       Waiting for connection on port 8888
-
-   Then start and connect a client from the same or another machine:
-
-       $ py.py -o thunk sharedref.py ip_or_name:8888
-       Connecting to ('...', 8888)
-       Ok
-       >>> l = [1,2,3]
-       >>> chan.send(l)    # send the list to the server over the connexion
-
-   On the server-side:
-
-       Connected from ('...', 1046)
-       >>> l = chan.recv()    # receive the list sent above
-       >>> l
-       [1, 2, 3]
-       >>> l.append(4)
-
-   Back on the client-side:
-
-       >>> l
-       [1, 2, 3, 4]
-
-   The list behaves like a single distributed object, which both sides can
-   modify and access without needing further explicit synchronization.
-   There is no difference between who was the original sender or receiver of
-   the object, nor between which side was originally 'server' or 'client'.
-"""
-
-import sys, marshal
-from __pypy__ import thunk, become
-from socket import *
-from select import select
-
-
-class Channel:
-
-    def __init__(self, s, serverside):
-        # invariants: a shared object 'obj' is
-        #  - either remote, and a thunk, and not a value in self.cache
-        #  - or local (or at least on "our" side of this Channel), and
-        #    then it has a corresponding key in self.cache
-        self.s = s
-        self.cache = {}
-        self.inputfifo = []
-        self.count = int(not serverside)
-
-##    def _check(self, obj):
-##        print '%s: cache=%r' % (self, self.cache.keys()),
-##        if is_thunk(obj):
-##            print 'THUNK'
-##        else:
-##            print obj
-
-    def sendraw(self, obj):
-        data = marshal.dumps(obj)
-        hdr = str(len(data))
-        hdr = '0'*(10-len(hdr)) + hdr
-        self.s.sendall(hdr + data)
-
-    def _readbytes(self, count):
-        data = ''
-        while len(data) < count:
-            t = self.s.recv(count - len(data))
-            if not t:
-                raise EOFError
-            data += t
-        return data
-
-    def recvraw(self):
-        datasize = int(self._readbytes(10))
-        data = self._readbytes(datasize)
-        return marshal.loads(data)
-
-    def send(self, obj, n=None):
-        #print 'send', n,; self._check(obj)
-        if n is None:
-            n = self.count
-            self.count += 2
-            data = (n, obj, None)
-        else:
-            data = (n, obj)
-        self.sendraw(data)
-        become(obj, thunk(self._resume, n))
-        #print 'done', n,; self._check(obj)
-
-    def recv(self):
-        obj = self.inputfifo.pop(0)
-        #print 'recv',; self._check(obj)
-        return obj
-
-    def _resume(self, n):
-        #print 'resume', n,; sys.stdout.flush()
-        assert n not in self.cache
-        self.sendraw((n,))
-        while n not in self.cache:
-            self.handle_once()
-        obj = self.cache[n]
-        #self._check(obj)
-        return obj
-
-    def handle_once(self):
-        input = self.recvraw()
-        if len(input) > 1:
-            obj = input[1]
-            self.cache[input[0]] = obj
-            if len(input) > 2:
-                self.inputfifo.append(obj)
-        else:
-            n = input[0]
-            obj = self.cache[n]
-            self.send(obj, n)
-            del self.cache[n]
-
-
-def mainloop(channels):
-    stdin = sys.stdin.fileno()
-    sockfd = [chan.s.fileno() for chan in channels]
-    while True:
-        sys.stdout.write('>>> ')
-        sys.stdout.flush()
-        while True:
-            iwtd, owtd, ewtd = select([stdin] + sockfd, [], [stdin])
-            if stdin in iwtd or stdin in ewtd: break
-            for chan in channels:
-                if chan.s.fileno() in iwtd:
-                    chan.handle_once()
-        code = raw_input()
-        if not code: break
-        try:
-            co = compile(code, '<input>', 'single')
-            exec co in globals()
-        except Exception, e:
-            print e.__class__.__name__, str(e)
-
-
-def server(port):
-    s = socket(AF_INET, SOCK_STREAM)
-    s.bind(('', port))
-    s.listen(1)
-    print 'Waiting for connection on port', port
-    s, addr = s.accept()
-    print 'Connected from', addr
-    return Channel(s, True)
-
-def client(addr):
-    s = socket(AF_INET, SOCK_STREAM)
-    print 'Connecting to', addr
-    s.connect(addr)
-    print 'Ok'
-    return Channel(s, False)
-
-
-if __name__ == '__main__':
-    try:
-        thunk, become    # only available in 'py.py -o thunk'
-    except NameError:
-        print __doc__
-        raise SystemExit(2)
-
-    channels = []
-    for a in sys.argv[1:]:
-        try:
-            port = int(a)
-        except ValueError:
-            host, port = a.split(':')
-            port = int(port)
-            chan = client((host, port))
-        else:
-            chan = server(port)
-        channels.append(chan)
-
-    try:
-        mainloop(channels)
-    finally:
-        for channel in channels:
-                channel.s.close()

File demo/tproxy/persistence.py

-"""
-
-This small example implements a basic orthogonal persistence 
-mechanism on top of PyPy's transparent proxies. 
-
-"""
-from tputil import make_proxy
-
-list_changeops = set('__iadd__ __imul__ __delitem__ __setitem__ __setattr__'
-                     '__delslice__ __setslice__ '
-                     'append extend insert pop remove reverse sort'.split())
-
-dict_changeops = set('__delitem__ __setitem__  __setattr__'
-                     'clear pop popitem setdefault update'.split())
-
-def ischangeop(operation): 
-    """ return True if this operation is a changing operation 
-        on known builtins (dicts, lists). 
-    """ 
-    if isinstance(operation.obj, list):
-        changeops = list_changeops 
-    elif isinstance(operation.obj, dict):
-        changeops = dict_changeops 
-    else:
-        return False
-    return operation.opname in changeops 
-
-def make_persistent_proxy(instance, storage): 
-    def perform(operation): 
-        res = operation.delegate()
-        if ischangeop(operation):
-            print "persisting after:", operation 
-            storage.dump(instance)
-        if res is not operation.proxyobj and isinstance(res, (dict, list)):
-            res = make_proxy(perform, obj=res)
-        return res
-    return make_proxy(perform, obj=instance) 
-
-def load(storage):
-    obj = storage.load()
-    return make_persistent_proxy(obj, storage) 
-    
-if __name__ == '__main__': 
-    import py 
-    storage = py.path.local("/tmp/dictpickle")
-    pdict = make_persistent_proxy({}, storage) 
-
-    # the code below is not aware of pdict being a proxy 
-    assert type(pdict) is dict
-    pdict['hello'] = 'world'       
-    pdict['somelist'] = []
-    del pdict 
-
-    newdict = load(storage) 
-    assert newdict == {'hello': 'world', 'somelist': []}
-    l = newdict['somelist']  
-    l.append(1)              # this triggers persisting the whole dict 
-    l.extend([2,3])          # this triggers persisting the whole dict 
-    del newdict, l 
-    
-    newdict = load(storage)
-    print newdict['somelist']   # will show [1,2,3]

File demo/tproxy/print_operations.py

-"""
-
-This example transparently intercepts and shows operations on 
-builtin objects.  Requires the "--objspace-std-withtproxy" option. 
-
-"""
-
-from tputil import make_proxy 
-
-def make_show_proxy(instance):
-    def controller(operation):
-        print "proxy sees:", operation
-        res = operation.delegate()
-        return res
-    tproxy = make_proxy(controller, obj=instance)
-    return tproxy
-
-if __name__ == '__main__':
-    mydict = make_show_proxy({}) 
-    assert type(mydict) is dict            # this looks exactly like a dict 
-    mydict['hello'] = 'world'              # will print __setitem__
-    mydict[42] = 23                        # will print __setitem__
-    assert mydict.pop('hello') == 'world'  # will print pop
-    assert mydict.popitem() == (42,23)     # will print popitem
-
-

File lib-python/2.7/json/decoder.py

 
 DEFAULT_ENCODING = "utf-8"
 
-def py_scanstring(s, end, encoding=None, strict=True,
-        _b=BACKSLASH, _m=STRINGCHUNK.match):
+def py_scanstring(s, end, encoding=None, strict=True):
     """Scan the string s for a JSON string. End is the index of the
     character in s after the quote that started the JSON string.
     Unescapes all valid JSON string escape sequences and raises ValueError
     _append = chunks.append
     begin = end - 1
     while 1:
-        chunk = _m(s, end)
+        chunk = STRINGCHUNK.match(s, end)
         if chunk is None:
             raise ValueError(
                 errmsg("Unterminated string starting at", s, begin))
         # If not a unicode escape sequence, must be in the lookup table
         if esc != 'u':
             try:
-                char = _b[esc]
+                char = BACKSLASH[esc]
             except KeyError:
                 msg = "Invalid \\escape: " + repr(esc)
                 raise ValueError(errmsg(msg, s, end))
 WHITESPACE_STR = ' \t\n\r'
 
 def JSONObject(s_and_end, encoding, strict, scan_once, object_hook,
-               object_pairs_hook, _w=WHITESPACE.match, _ws=WHITESPACE_STR):
+               object_pairs_hook):
     s, end = s_and_end
     pairs = []
     pairs_append = pairs.append
     nextchar = s[end:end + 1]
     # Normally we expect nextchar == '"'
     if nextchar != '"':
-        if nextchar in _ws:
-            end = _w(s, end).end()
+        if nextchar in WHITESPACE_STR:
+            end = WHITESPACE.match(s, end).end()
             nextchar = s[end:end + 1]
         # Trivial empty object
         if nextchar == '}':
         # To skip some function call overhead we optimize the fast paths where
         # the JSON key separator is ": " or just ":".
         if s[end:end + 1] != ':':
-            end = _w(s, end).end()
+            end = WHITESPACE.match(s, end).end()
             if s[end:end + 1] != ':':
                 raise ValueError(errmsg("Expecting : delimiter", s, end))
 
         end += 1
 
         try:
-            if s[end] in _ws:
+            if s[end] in WHITESPACE_STR:
                 end += 1
-                if s[end] in _ws:
-                    end = _w(s, end + 1).end()
+                if s[end] in WHITESPACE_STR:
+                    end = WHITESPACE.match(s, end + 1).end()
         except IndexError:
             pass
 
 
         try:
             nextchar = s[end]
-            if nextchar in _ws:
-                end = _w(s, end + 1).end()
+            if nextchar in WHITESPACE_STR:
+                end = WHITESPACE.match(s, end + 1).end()
                 nextchar = s[end]
         except IndexError:
             nextchar = ''
 
         try:
             nextchar = s[end]
-            if nextchar in _ws:
+            if nextchar in WHITESPACE_STR:
                 end += 1
                 nextchar = s[end]
-                if nextchar in _ws:
-                    end = _w(s, end + 1).end()
+                if nextchar in WHITESPACE_STR:
+                    end = WHITESPACE.match(s, end + 1).end()
                     nextchar = s[end]
         except IndexError:
             nextchar = ''
         pairs = object_hook(pairs)
     return pairs, end
 
-def JSONArray(s_and_end, scan_once, _w=WHITESPACE.match, _ws=WHITESPACE_STR):
+def JSONArray(s_and_end, scan_once):
     s, end = s_and_end
     values = []
     nextchar = s[end:end + 1]
-    if nextchar in _ws:
-        end = _w(s, end + 1).end()
+    if nextchar in WHITESPACE_STR:
+        end = WHITESPACE.match(s, end + 1).end()
         nextchar = s[end:end + 1]
     # Look-ahead for trivial empty array
     if nextchar == ']':
             raise ValueError(errmsg("Expecting object", s, end))
         _append(value)
         nextchar = s[end:end + 1]
-        if nextchar in _ws:
-            end = _w(s, end + 1).end()
+        if nextchar in WHITESPACE_STR:
+            end = WHITESPACE.match(s, end + 1).end()
             nextchar = s[end:end + 1]
         end += 1
         if nextchar == ']':
             raise ValueError(errmsg("Expecting , delimiter", s, end))
 
         try:
-            if s[end] in _ws:
+            if s[end] in WHITESPACE_STR:
                 end += 1
-                if s[end] in _ws:
-                    end = _w(s, end + 1).end()
+                if s[end] in WHITESPACE_STR:
+                    end = WHITESPACE.match(s, end + 1).end()
         except IndexError:
             pass
 
         self.parse_string = scanstring
         self.scan_once = scanner.make_scanner(self)
 
-    def decode(self, s, _w=WHITESPACE.match):
+    def decode(self, s):
         """Return the Python representation of ``s`` (a ``str`` or ``unicode``
         instance containing a JSON document)
 
         """
-        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
-        end = _w(s, end).end()
+        obj, end = self.raw_decode(s, idx=WHITESPACE.match(s, 0).end())
+        end = WHITESPACE.match(s, end).end()
         if end != len(s):
             raise ValueError(errmsg("Extra data", s, end, len(s)))
         return obj

File pypy/config/pypyoption.py

-import autopath
-import py, os
 import sys
-from pypy.config.config import OptionDescription, BoolOption, IntOption, ArbitraryOption
-from pypy.config.config import ChoiceOption, StrOption, to_optparse, Config
-from pypy.config.config import ConflictConfigError
+
+import py
+
+from pypy.config.config import (OptionDescription, BoolOption, IntOption,
+  ChoiceOption, StrOption, to_optparse, ConflictConfigError)
 from pypy.config.translationoption import IS_64_BITS
 
+
 modulepath = py.path.local(__file__).dirpath().dirpath().join("module")
 all_modules = [p.basename for p in modulepath.listdir()
                if p.check(dir=True, dotfile=False)
 
 
 pypy_optiondescription = OptionDescription("objspace", "Object Space Options", [
-    ChoiceOption("name", "Object Space name",
-                 ["std", "flow", "thunk", "dump"],
-                 "std",
-                 cmdline='--objspace -o'),
-
     OptionDescription("opcodes", "opcodes to enable in the interpreter", [
         BoolOption("CALL_METHOD", "emit a special bytecode for expr.name()",
                    default=False),
         ]),
 
-    BoolOption("nofaking", "disallow faking in the object space",
-               default=False,
-               requires=[
-                   ("objspace.usemodules.posix", True),
-                   ("objspace.usemodules.time", True),
-                   ("objspace.usemodules.errno", True)],
-               cmdline='--nofaking'),
-
     OptionDescription("usemodules", "Which Modules should be used", [
         BoolOption(modname, "use module %s" % (modname, ),
                    default=modname in default_modules,
                cmdline="--translationmodules",
                suggests=[("objspace.allworkingmodules", False)]),
 
-    BoolOption("logbytecodes",
-               "keep track of bytecode usage",
-               default=False),
-
     BoolOption("usepycfiles", "Write and read pyc files when importing",
                default=True),
 
                "make sure that all calls go through space.call_args",
                default=False),
 
-    BoolOption("timing",
-               "timing of various parts of the interpreter (simple profiling)",
-               default=False),
-
     OptionDescription("std", "Standard Object Space Options", [
         BoolOption("withtproxy", "support transparent proxies",
                    default=True),
                    requires=[("objspace.std.withsmallint", False)]),
                              #  ^^^ because of missing delegate_xx2yy
 
-        BoolOption("withstrjoin", "use strings optimized for addition",
-                   default=False),
-
-        BoolOption("withstrslice", "use strings optimized for slicing",
-                   default=False),
-
         BoolOption("withstrbuf", "use strings optimized for addition (ver 2)",
                    default=False),
 
                    "use specialised tuples",
                    default=False),
 
-        BoolOption("withrope", "use ropes as the string implementation",
-                   default=False,
-                   requires=[("objspace.std.withstrslice", False),
-                             ("objspace.std.withstrjoin", False),
-                             ("objspace.std.withstrbuf", False)],
-                   suggests=[("objspace.std.withprebuiltchar", True),
-                             ("objspace.std.sharesmallstr", True)]),
-
-        BoolOption("withropeunicode", "use ropes for the unicode implementation",
-                   default=False,
-                   requires=[("objspace.std.withrope", True)]),
-
         BoolOption("withcelldict",
                    "use dictionaries that are optimized for being used as module dicts",
                    default=False,
                    # weakrefs needed, because of get_subclasses()
                    requires=[("translation.rweakref", True)]),
 
-        BoolOption("logspaceoptypes",
-                   "a instrumentation option: before exit, print the types seen by "
-                   "certain simpler bytecodes",
-                   default=False),
         ChoiceOption("multimethods", "the multimethod implementation to use",
                      ["doubledispatch", "mrd"],
                      default="mrd"),
-        BoolOption("mutable_builtintypes",
-                   "Allow the changing of builtin types", default=False,
-                   requires=[("objspace.std.builtinshortcut", True)]),
         BoolOption("withidentitydict",
                    "track types that override __hash__, __eq__ or __cmp__ and use a special dict strategy for those which do not",
                    default=False,
         config.objspace.std.suggest(withprebuiltint=True)
         config.objspace.std.suggest(withprebuiltchar=True)
         config.objspace.std.suggest(withmapdict=True)
-        config.objspace.std.suggest(withstrslice=True)
-        config.objspace.std.suggest(withstrjoin=True)
         if not IS_64_BITS:
             config.objspace.std.suggest(withsmalllong=True)
-        # xxx other options? ropes maybe?
 
     # some optimizations have different effects depending on the typesystem
     if type_system == 'ootype':

File pypy/config/test/test_config.py

 def make_description():
     gcoption = ChoiceOption('name', 'GC name', ['ref', 'framework'], 'ref')
     gcdummy = BoolOption('dummy', 'dummy', default=False)
-    objspaceoption = ChoiceOption('objspace', 'Object space',
-                                ['std', 'thunk'], 'std')
     booloption = BoolOption('bool', 'Test boolean option', default=True)
     intoption = IntOption('int', 'Test int option', default=0)
     floatoption = FloatOption('float', 'Test float option', default=2.3)
                                       requires=[('gc.name', 'framework')])
     
     gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption])
-    descr = OptionDescription('pypy', '', [gcgroup, booloption, objspaceoption,
+    descr = OptionDescription('pypy', '', [gcgroup, booloption,
                                            wantref_option, stroption,
                                            wantframework_option,
                                            intoption])
 def test_base_config():
     descr = make_description()
     config = Config(descr, bool=False)
-    
+
     assert config.gc.name == 'ref'
     config.gc.name = 'framework'
     assert config.gc.name == 'framework'
     assert getattr(config, "gc.name") == 'framework'
 
-    assert config.objspace == 'std'
-    config.objspace = 'thunk'
-    assert config.objspace == 'thunk'
-    
     assert config.gc.float == 2.3
     assert config.int == 0
     config.gc.float = 3.4
     config.str = "def"
     assert config.str == "def"
 
-    py.test.raises(ConfigError, 'config.objspace = "foo"')
     py.test.raises(ConfigError, 'config.gc.name = "foo"')
     py.test.raises(AttributeError, 'config.gc.foo = "bar"')
     py.test.raises(ConfigError, 'config.bool = 123')
     assert '_cfgimpl_values' in attrs # from self
     if sys.version_info >= (2, 6):
         assert 'gc' in attrs              # custom attribute
-        assert 'objspace' in attrs        # custom attribute
     #
     attrs = dir(config.gc)
     if sys.version_info >= (2, 6):
     config = Config(descr)
     
     assert config.getpaths() == ['gc.name', 'gc.dummy', 'gc.float', 'bool',
-                                 'objspace', 'wantref', 'str', 'wantframework',
+                                 'wantref', 'str', 'wantframework',
                                  'int']
     assert config.getpaths() == descr.getpaths()
     assert config.gc.getpaths() == ['name', 'dummy', 'float']
     assert config.gc.getpaths() == descr.gc.getpaths()
     assert config.getpaths(include_groups=True) == [
         'gc', 'gc.name', 'gc.dummy', 'gc.float',
-        'bool', 'objspace', 'wantref', 'str', 'wantframework', 'int']
+        'bool', 'wantref', 'str', 'wantframework', 'int']
     assert config.getpaths(True) == descr.getpaths(True)
 
 def test_underscore_in_option_name():

File pypy/config/test/test_parse.py

     assert (parse_info("                          objspace.allworkingmodules: True\n"
                        "                    objspace.disable_call_speedhacks: False\n"
                        "                                 objspace.extmodules: None\n"
-                       "                                       objspace.name: std\n"
                        "                        objspace.std.prebuiltintfrom: -5\n")
             == {
         'objspace.allworkingmodules': True,
         'objspace.disable_call_speedhacks': False,
         'objspace.extmodules': None,
-        'objspace.name': 'std',
         'objspace.std.prebuiltintfrom': -5,
         })

File pypy/config/test/test_pypyoption.py

 
 
 def test_frameworkgc():
-    for name in ["marksweep", "semispace"]:
+    for name in ["minimark", "semispace"]:
         conf = get_pypy_config()
         assert conf.translation.gctransformer != "framework"
         conf.translation.gc = name

File pypy/config/translationoption.py

 
     # gc
     ChoiceOption("gc", "Garbage Collection Strategy",
-                 ["boehm", "ref", "marksweep", "semispace", "statistics",
-                  "generation", "hybrid", "markcompact", "minimark", "none"],
+                 ["boehm", "ref", "semispace", "statistics",
+                  "generation", "hybrid", "minimark", "none"],
                   "ref", requires={
                      "ref": [("translation.rweakref", False), # XXX
                              ("translation.gctransformer", "ref")],
                      "none": [("translation.rweakref", False), # XXX
                              ("translation.gctransformer", "none")],
                      "semispace": [("translation.gctransformer", "framework")],
-                     "marksweep": [("translation.gctransformer", "framework")],
                      "statistics": [("translation.gctransformer", "framework")],
                      "generation": [("translation.gctransformer", "framework")],
                      "hybrid": [("translation.gctransformer", "framework")],
                      "boehm": [("translation.continuation", False),  # breaks
                                ("translation.gctransformer", "boehm")],
-                     "markcompact": [("translation.gctransformer", "framework")],
                      "minimark": [("translation.gctransformer", "framework")],
                      },
                   cmdline="--gc"),
 
     # misc
     BoolOption("verbose", "Print extra information", default=False),
-    BoolOption("insist", "Try hard to go on RTyping", default=False,
-               cmdline="--insist"),
     StrOption("cc", "Specify compiler to use for compiling generated C", cmdline="--cc"),
     StrOption("profopt", "Specify profile based optimization script",
               cmdline="--profopt"),
                default=False, requires=[("translation.backend", "c")]),
 
     # portability options
-    BoolOption("vanilla",
-               "Try to be as portable as possible, which is not much",
-               default=False,
-               cmdline="--vanilla",
-               requires=[("translation.no__thread", True)]),
     BoolOption("no__thread",
                "don't use __thread for implementing TLS",
                default=False, cmdline="--no__thread", negation=False),

File pypy/doc/__pypy__-module.rst

    It works like a simplified array of characters (actually, depending on the
    configuration the ``array`` module internally uses this).
 
-Thunk Object Space Functionality
-================================
-
-When the thunk object space is used (choose with :config:`objspace.name`),
-the following functions are put into ``__pypy__``:
-
- - ``thunk``
- - ``is_thunk``
- - ``become``
- - ``lazy``
-
-Those are all described in the `interface section of the thunk object space
-docs`_.
-
-For explanations and examples see the `thunk object space docs`_.
-
-.. _`thunk object space docs`: objspace-proxies.html#thunk
-.. _`interface section of the thunk object space docs`: objspace-proxies.html#thunk-interface
-
-
 Transparent Proxy Functionality
 ===============================
 

File pypy/doc/_ref.txt

 .. _`pypy/module/__builtin__/__init__.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/module/__builtin__/__init__.py
 .. _`pypy/objspace`:
 .. _`pypy/objspace/`: https://bitbucket.org/pypy/pypy/src/default/pypy/objspace/
-.. _`pypy/objspace/dump.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/objspace/dump.py
 .. _`pypy/objspace/flow`:
 .. _`pypy/objspace/flow/`: https://bitbucket.org/pypy/pypy/src/default/pypy/objspace/flow/
 .. _`pypy/objspace/flow/model.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/objspace/flow/model.py
 .. _`pypy/objspace/std/transparent.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/objspace/std/transparent.py
 .. _`pypy/objspace/std/tupleobject.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/objspace/std/tupleobject.py
 .. _`pypy/objspace/std/tupletype.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/objspace/std/tupletype.py
-.. _`pypy/objspace/thunk.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/objspace/thunk.py
-.. _`pypy/objspace/trace.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/objspace/trace.py
 .. _`pypy/rlib`:
 .. _`pypy/rlib/`: https://bitbucket.org/pypy/pypy/src/default/pypy/rlib/
 .. _`pypy/rlib/listsort.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rlib/listsort.py

File pypy/doc/config/objspace.logbytecodes.txt

-Internal option.
-
-.. internal

File pypy/doc/config/objspace.name.txt

-Determine which `Object Space`_ to use. The `Standard Object Space`_ gives the
-normal Python semantics, the others are `Object Space Proxies`_ giving
-additional features (except the Flow Object Space which is not intended
-for normal usage):
-
-  * thunk_: The thunk object space adds lazy evaluation to PyPy.
-  * dump_:  Using this object spaces results in the dumpimp of all operations
-    to a log.
-
-.. _`Object Space`: ../objspace.html
-.. _`Object Space Proxies`: ../objspace-proxies.html
-.. _`Standard Object Space`: ../objspace.html#standard-object-space
-.. _thunk: ../objspace-proxies.html#thunk
-.. _dump: ../objspace-proxies.html#dump

File pypy/doc/config/objspace.std.logspaceoptypes.txt

-.. internal
-
-Wrap "simple" bytecode implementations like BINARY_ADD with code that collects
-information about which types these bytecodes receive as arguments.

File pypy/doc/config/objspace.std.mutable_builtintypes.txt

-Allow modification of builtin types.  Disabled by default.

File pypy/doc/config/objspace.std.withrope.txt

-Enable ropes to be the default string implementation.
-
-See the section in `Standard Interpreter Optimizations`_ for more details.
-
-.. _`Standard Interpreter Optimizations`: ../interpreter-optimizations.html#ropes
-
-

File pypy/doc/config/objspace.std.withropeunicode.txt

-Use ropes to implement unicode strings (and also normal strings).
-
-See the section in `Standard Interpreter Optimizations`_ for more details.
-
-.. _`Standard Interpreter Optimizations`: ../interpreter-optimizations.html#ropes
-
-

File pypy/doc/config/objspace.std.withstrjoin.txt

-Enable "string join" objects.
-
-See the page about `Standard Interpreter Optimizations`_ for more details.
-
-.. _`Standard Interpreter Optimizations`: ../interpreter-optimizations.html#string-join-objects
-
-

File pypy/doc/config/objspace.std.withstrslice.txt

-Enable "string slice" objects.
-
-See the page about `Standard Interpreter Optimizations`_ for more details.
-
-.. _`Standard Interpreter Optimizations`: ../interpreter-optimizations.html#string-slice-objects
-
-

File pypy/doc/config/objspace.timing.txt

-timing of various parts of the interpreter (simple profiling)

File pypy/doc/config/translation.insist.txt

-Don't stop on the first `rtyping`_ error. Instead, try to rtype as much as
-possible and show the collected error messages in the end.
-
-.. _`rtyping`: ../rtyper.html

File pypy/doc/config/translation.no__thread.txt

 Don't use gcc __thread attribute for fast thread local storage
 implementation . Increases the chance that moving the resulting
-executable to another same processor Linux machine will work. (see
-:config:`translation.vanilla`).
+executable to another same processor Linux machine will work.

File pypy/doc/garbage_collection.rst

 Mark and Sweep
 --------------
 
-Classical Mark and Sweep collector.  Also contains a lot of experimental
-and half-unmaintained features.  See `pypy/rpython/memory/gc/marksweep.py`_.
+Classical Mark and Sweep collector.  Also contained a lot of experimental
+and half-unmaintained features.  Was removed.
 
 Semispace copying collector
 ---------------------------
 Mark & Compact GC
 -----------------
 
+Killed in trunk.  The following documentation is for historical purposes
+only.
+
 Inspired, at least partially, by Squeak's garbage collector, this is a
 single-arena GC in which collection compacts the objects in-place.  The
 main point of this GC is to save as much memory as possible (to be not
 objects' header, in order to let the collector store temporary relation
 information in the regular headers.
 
-More details are available as comments at the start of the source
-in `pypy/rpython/memory/gc/markcompact.py`_.
-
 Minimark GC
 -----------
 

File pypy/doc/getting-started-dev.rst

    and grammar files that allow it to parse the syntax of various Python
    versions. Once the grammar has been processed, the parser can be
    translated by the above machinery into efficient code.
- 
+
 *  `pypy/interpreter/astcompiler`_ contains the compiler.  This
    contains a modified version of the compiler package from CPython
    that fixes some bugs and is translatable.
    ``xxxobject.py`` contain respectively the definition of the type and its
    (default) implementation.
 
-*  `pypy/objspace`_ contains a few other object spaces: the `pypy/objspace/thunk.py`_,
-   `pypy/objspace/trace.py`_ and `pypy/objspace/flow`_ object spaces.  The latter is a relatively short piece
-   of code that builds the control flow graphs when the bytecode interpreter
-   runs in it.
-
 *  `pypy/translator`_ contains the code analysis and generation stuff.
    Start reading from translator.py, from which it should be easy to follow
    the pieces of code involved in the various translation phases.

File pypy/doc/getting-started-python.rst

 
 .. _`configuration sections`: config/index.html
 
-.. _`translate PyPy with the thunk object space`:
-
 Translating with non-standard options
 ++++++++++++++++++++++++++++++++++++++++
 

File pypy/doc/index.rst

 
 `pypy/objspace/`_                  `object space`_ implementations
 
-`pypy/objspace/trace.py`_          the `trace object space`_ monitoring bytecode and space operations
-
-`pypy/objspace/dump.py`_           the dump object space saves a large, searchable log file
-                                   with all operations
-
-`pypy/objspace/thunk.py`_          the `thunk object space`_, providing unique object features 
-
 `pypy/objspace/flow/`_             the FlowObjSpace_ implementing `abstract interpretation`_
 
 `pypy/objspace/std/`_              the StdObjSpace_ implementing CPython's objects and types
 .. _`basil`: http://people.cs.uchicago.edu/~jriehl/BasilTalk.pdf
 .. _`object space`: objspace.html
 .. _FlowObjSpace: objspace.html#the-flow-object-space 
-.. _`trace object space`: objspace.html#the-trace-object-space 
-.. _`thunk object space`: objspace-proxies.html#thunk
 .. _`transparent proxies`: objspace-proxies.html#tproxy
 .. _`Differences between PyPy and CPython`: cpython_differences.html
 .. _`What PyPy can do for your objects`: objspace-proxies.html

File pypy/doc/interpreter-optimizations.rst

 Object Optimizations
 ====================
 
-String Optimizations
---------------------
-
-String-Join Objects
-+++++++++++++++++++
-
-String-join objects are a different implementation of the Python ``str`` type,
-They represent the lazy addition of several strings without actually performing
-the addition (which involves copying etc.). When the actual value of the string
-join object is needed, the addition is performed. This makes it possible to
-perform repeated string additions in a loop without using the
-``"".join(list_of_strings)`` pattern.
-
-You can enable this feature enable with the :config:`objspace.std.withstrjoin`
-option.
-
-String-Slice Objects
-++++++++++++++++++++
-
-String-slice objects are another implementation of the Python ``str`` type.
-They represent the lazy slicing of a string without actually performing the
-slicing (which would involve copying). This is only done for slices of step
-one. When the actual value of the string slice object is needed, the slicing
-is done (although a lot of string methods don't make this necessary). This
-makes string slicing a very efficient operation. It also saves memory in some
-cases but can also lead to memory leaks, since the string slice retains a
-reference to the original string (to make this a bit less likely, we don't
-use lazy slicing when the slice would be much shorter than the original
-string.  There is also a minimum number of characters below which being lazy
-is not saving any time over making the copy).
-
-You can enable this feature with the :config:`objspace.std.withstrslice` option.
-
-Ropes
-+++++
-
-Ropes are a general flexible string implementation, following the paper `"Ropes:
-An alternative to Strings."`_ by Boehm, Atkinson and Plass. Strings are
-represented as balanced concatenation trees, which makes slicing and
-concatenation of huge strings efficient.
-
-Using ropes is usually not a huge benefit for normal Python programs that use
-the typical pattern of appending substrings to a list and doing a
-``"".join(l)`` at the end. If ropes are used, there is no need to do that.
-A somewhat silly example of things you can do with them is this::
-
-    $ bin/py.py --objspace-std-withrope
-    faking <type 'module'>
-    PyPy 1.5.0-alpha0 in StdObjSpace on top of Python 2.7.1+ (startuptime: 11.38 secs)
-    >>>> import sys
-    >>>> sys.maxint
-    2147483647
-    >>>> s = "a" * sys.maxint
-    >>>> s[10:20]
-    'aaaaaaaaaa'
-
-
-You can enable this feature with the :config:`objspace.std.withrope` option.
-
-.. _`"Ropes: An alternative to Strings."`: http://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.14.9450&rep=rep1&type=pdf
-
-
 Integer Optimizations
 ---------------------
 

File pypy/doc/objspace-proxies.rst

 
 Here is what we have implemented so far, in historical order:
 
-* *Thunk Object Space*: lazily computed objects, computing only when an
-  operation is performed on them; lazy functions, computing their result
-  only if and when needed; and a way to globally replace an object with
-  another.
-
 * *Dump Object Space*: dumps all operations performed on all the objects
   into a large log file.  For debugging your applications.
 
 * *Transparent Proxies Extension*: adds new proxy objects to
-  the Standard Object Space that enable applications to 
-  control operations on application and builtin objects, 
-  e.g lists, dictionaries, tracebacks. 
-
-Which object space to use can be chosen with the :config:`objspace.name`
-option.
+  the Standard Object Space that enable applications to
+  control operations on application and builtin objects,
+  e.g lists, dictionaries, tracebacks.
 
 .. _`Object Space`: objspace.html
-
-.. _thunk:
-
-The Thunk Object Space
-======================
-
-This small object space, meant as a nice example, wraps another object
-space (e.g. the standard one) and adds two capabilities: lazily computed
-objects, computed only when an operation is performed on them, and
-"become", a more obscure feature which allows to completely and globally
-replaces an object with another.
-
-Example usage of lazily computed objects::
-
-    $ py.py -o thunk
-    >>>> from __pypy__ import thunk
-    >>>> def f():
-    ....    print 'computing...'
-    ....    return 6*7
-    ....
-    >>>> x = thunk(f)
-    >>>> x
-    computing...
-    42
-    >>>> x
-    42
-    >>>> y = thunk(f)
-    >>>> type(y)
-    computing...
-    <type 'int'>
-
-Example of how one object can be instantly and globally replaced with
-another::
-
-    $ py.py -o thunk
-    >>>> from __pypy__ import become
-    >>>> x = object()
-    >>>> lst = [1, 2, x, 4]
-    >>>> become(x, 3)
-    >>>> lst
-    [1, 2, 3, 4]
-
-There is also a decorator for functions whose result can be computed
-lazily (the function appears to return a result, but it is not really
-invoked before the result is used, if at all)::
-
-    $ py.py -o thunk
-    >>>> from __pypy__ import lazy
-    >>>> @lazy
-    .... def f(x):
-    ....    print 'computing...'
-    ....    return x * 100
-    ....
-    >>>> lst = [f(i) for i in range(10)]
-    >>>> del lst[1:9]
-    >>>> lst
-    computing...
-    computing...
-    [0, 900]
-
-Implementation
---------------
-
-The implementation is short (see `pypy/objspace/thunk.py`_).  For the
-purpose of ``become()``, it adds an internal field `w_thunkalias` to
-each object, which is either None (in the common case) or a reference to
-the object that this object was replaced with.  When any space operation
-is invoked, the chain of ``w_thunkalias`` references is followed and the
-underlying object space really operates on the new objects instead of
-the old ones.
-
-For the laziness part, the function ``thunk()`` returns an instance of a
-new internal class ``W_Thunk`` which stores the user-supplied callable
-and arguments.  When a space operation follows the ``w_thunkalias``
-chains of objects, it special-cases ``W_Thunk``: it invokes the stored
-callable if necessary to compute the real value and then stores it in
-the ``w_thunkalias`` field of the ``W_Thunk``.  This has the effect of
-replacing the latter with the real value.
-
-.. _thunk-interface:
-
-Interface
----------
-
-In a PyPy running with (or translated with) the Thunk Object Space,
-the ``__pypy__`` module exposes the following interface:
-
- * ``thunk(f, *args, **kwargs)``: returns something that behaves like the result
-   of the call ``f(*args, **kwargs)`` but the call is done lazily.
-
- * ``is_thunk(obj)``: return True if ``obj`` is a thunk that is not computed
-   yet.
-
- * ``become(obj1, obj2)``: globally replace ``obj1`` with ``obj2``.
-
- * ``lazy(callable)``: should be used as a function decorator - the decorated
-   function behaves lazily: all calls to it return a thunk object.
-
-
-.. _dump:
-
-The Dump Object Space
-=====================
-
-When PyPy is run with (or translated with) the *Dump Object Space*, all
-operations between objects are dumped to a file called
-``pypy-space-dump``.  This should give a powerful way to debug
-applications, but so far the dump can only be inspected in a text
-editor; better browsing tools are needed before it becomes really useful.
-
-Try::
-
-    $ py.py -o dump
-    >>>> 2+3
-    5
-    >>>> (exit py.py here)
-    $ more pypy-space-dump
-
-On my machine the ``add`` between 2 and 3 starts at line 3152 (!)  and
-returns at line 3164.  All the rest is start-up, printing, and shutdown.
-
-
 .. _tproxy:
 
 Transparent Proxies
 ================================
 
-PyPy's Transparent Proxies allow routing of operations on objects 
+PyPy's Transparent Proxies allow routing of operations on objects
 to a callable.  Application level code can customize objects without
 interfering with the type system - ``type(proxied_list) is list`` holds true
 when 'proxied_list' is a proxied built-in list - while
 giving you full control on all operations that are performed on the
 ``proxied_list``.
 
-See [D12.1]_ for more context, motivation and usage of transparent proxies. 
+See [D12.1]_ for more context, motivation and usage of transparent proxies.
 
-Example of the core mechanism 
+Example of the core mechanism
 -------------------------------------------
 
-The following example proxies a list and will 
-return ``42`` on any add operation to the list:: 
+The following example proxies a list and will
+return ``42`` on any add operation to the list::
 
-   $ py.py --objspace-std-withtproxy 
+   $ py.py --objspace-std-withtproxy
    >>>> from __pypy__ import tproxy
    >>>> def f(operation, *args, **kwargs):
    >>>>    if operation == '__add__':
 
    history = []
    def recorder(operation):
-       history.append(operation) 
+       history.append(operation)
        return operation.delegate()
 
-   >>>> l = make_proxy(recorder, obj=[])    
+   >>>> l = make_proxy(recorder, obj=[])
    >>>> type(l)
    list
    >>>> l.append(3)
    1
    >>>> len(history)
    2
-   
+
 ``make_proxy(recorder, obj=[])`` creates a transparent list
-proxy where we can delegate operations to in the ``recorder`` function. 
-Calling ``type(l)`` does not lead to any operation being executed at all. 
+proxy where we can delegate operations to in the ``recorder`` function.
+Calling ``type(l)`` does not lead to any operation being executed at all.
 
 Note that ``append`` shows up as ``__getattribute__`` and that ``type(lst)``
 does not show up at all - the type is the only aspect of the instance which
 the controller cannot change.
 
-.. _`transparent proxy builtins`: 
+.. _`transparent proxy builtins`:
 
 Transparent Proxy PyPy builtins and support
 -----------------------------------------------------------
 
-If you are using the `--objspace-std-withtproxy`_ option 
-the `__pypy__`_ module provides the following builtins: 
+If you are using the `--objspace-std-withtproxy`_ option
+the `__pypy__`_ module provides the following builtins:
 
-* ``tproxy(type, controller)``: returns a proxy object 
-  representing the given type and forwarding all operations 
+* ``tproxy(type, controller)``: returns a proxy object
+  representing the given type and forwarding all operations
   on this type to the controller.  On each such operation
-  ``controller(opname, *args, **kwargs)`` is invoked. 
+  ``controller(opname, *args, **kwargs)`` is invoked.
 
-* ``get_tproxy_controller(obj)``:  returns the responsible 
+* ``get_tproxy_controller(obj)``:  returns the responsible
   controller for a given object.  For non-proxied objects
-  ``None`` is returned.  
+  ``None`` is returned.
 
-.. _`__pypy__`:  __pypy__-module.html 
+.. _`__pypy__`:  __pypy__-module.html
 .. _`--objspace-std-withtproxy`: config/objspace.std.withtproxy.html
 
-.. _tputil: 
+.. _tputil:
 
-tputil helper module 
+tputil helper module
 ----------------------------
 
-The `lib_pypy/tputil.py`_ module provides: 
+The `lib_pypy/tputil.py`_ module provides:
 
-* ``make_proxy(controller, type, obj)``: function which 
-  creates a transparent proxy controlled by the given 
-  'controller' callable.  The proxy will appear 
-  as a completely regular instance of the given 
-  type but all operations on it are send to the 
+* ``make_proxy(controller, type, obj)``: function which
+  creates a transparent proxy controlled by the given
+  'controller' callable.  The proxy will appear
+  as a completely regular instance of the given
+  type but all operations on it are send to the
   specified controller - which receives a
-  ProxyOperation instance on each such operation.  
-  A non-specified type will default to type(obj) if 
-  `obj` was specified. 
+  ProxyOperation instance on each such operation.
+  A non-specified type will default to type(obj) if
+  `obj` was specified.
 
-  ProxyOperation instances have the following attributes: 
+  ProxyOperation instances have the following attributes:
 
-    `proxyobj`: the transparent proxy object of this operation. 
+    `proxyobj`: the transparent proxy object of this operation.
 
-    `opname`: the operation name of this operation 
+    `opname`: the operation name of this operation
 
-    `args`: positional arguments for this operation 
+    `args`: positional arguments for this operation
 
-    `kwargs`: keyword arguments for this operation 
+    `kwargs`: keyword arguments for this operation
 
     `obj`: (if provided to `make_proxy`): a concrete object
 
-  If you have specified a concrete object instance `obj` 
-  to your `make_proxy` invocation, you may call 
-  ``proxyoperation.delegate()`` to delegate the operation 
-  to this object instance. 
+  If you have specified a concrete object instance `obj`
+  to your `make_proxy` invocation, you may call
+  ``proxyoperation.delegate()`` to delegate the operation
+  to this object instance.
 
 Further points of interest
 ---------------------------
   SQL object mapper which looks like a real object)
 
 * Access to external data structures, such as other languages, as normal
-  objects (of course some operations could raise exceptions, but 
+  objects (of course some operations could raise exceptions, but
   since they are purely done on application level, that is not real problem)
 
 Implementation Notes
 
 PyPy's standard object space allows to internally have multiple
 implementations of a type and change the implementation at run
-time while application level code consistently sees the exact 
-same type and object.  Multiple performance optimizations using 
+time while application level code consistently sees the exact
+same type and object.  Multiple performance optimizations using
 this features are already implemented: see the document