Infinite Python Data Structures
6th October 2003
Hans Nowak has been churning out some really interesting Python stuff recently. He’s been experimenting with Self style objects in Python (similar in many respects to objects in Javascript), developing Wax, a coder friendly wrapper around wxPython, working on a Python framework for writing text adventure games and most recently experimenting with streams in Python using generators.
Streams are a fascinating concept: they provide a way of defining infinite sized data structures, such as an array of all numbers that are multiples of 7. By only calculuating items when they are requested these seemingly impossible data structures can exist and be processed in a similar way to normal arrays. As Hans points out, Python generators aren’t quite as elegant for this purpose as Scheme’s stream implementation or Haskell’s recurive list declarations but this use for them does help show why generators are such a powerful tool.
More recent articles
- Gemini 2.0 Flash: An outstanding multi-modal LLM with a sci-fi streaming mode - 11th December 2024
- ChatGPT Canvas can make API requests now, but it's complicated - 10th December 2024
- I can now run a GPT-4 class model on my laptop - 9th December 2024