Chapter 1

Good Old Times


1.1 Constraints

  • Very small amount of primary memory, typically orders of magnitude smaller than the data that needs to be processed/generated.
  • No identifiers – i.e. no variable names or tagged memory addresses. All we have is memory that is addressable with numbers.

1.2 A Program in this Style

  1 #!/usr/bin/env python
  3 import sys, os, string
  5 # Utility for handling the intermediate 'secondary memory'
  6 def touchopen(filename, *args, **kwargs):
  7 try:
  8  os.remove(filename)
  9 except OSError:
 10   pass
 11 open(filename, "a").close() # "touch" file
 12 return open(filename, *args, **kwargs)
 14 # The constrained memory ...

Get Exercises in Programming Style now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.