~washort/pymeta/ometa-2

« back to all changes in this revision

Viewing changes to pymeta/runtime.py

  • Committer: Allen Short
  • Date: 2008-07-12 04:14:30 UTC
  • Revision ID: washort@divmod.com-20080712041430-tgribkcom9tby0go
cache tails

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
        self.data = data
52
52
        self.position = position
53
53
        self.memo = {}
 
54
        self.tl = None
54
55
 
55
56
    def head(self):
56
57
        if self.position >= len(self.data):
58
59
        return self.data[self.position]
59
60
 
60
61
    def tail(self):
61
 
        return InputStream(self.data, self.position+1)
 
62
        if self.tl is None:
 
63
            self.tl = InputStream(self.data, self.position+1)
 
64
        return self.tl
62
65
 
63
66
    def prev(self):
64
67
        return InputStream(self.data, self.position-1)