Slow Parsing / Initialisation
First I wanted to say this project has been a lifesaver in helping me create a parser for a binary file that I knew very little about but needed to deconstruct. The WebIDE was great for tweaking and I managed to get a working parser with the following structure.

```ksy
meta:
  id: onions
seq:
  - id: records
    type: record
    repeat: eos
types:
  record:
    seq:
    - id: validity
      type: s1
    - id: allocated
      type: s8le
    - id: document
      type: str
      encoding: utf-8
      terminator: 1
      eos-error: false
```

It's essentially a parser for the [Go Tiedot data structure ](https://github.com/HouzuoGuo/tiedot/wiki/Data-structures) which I've found difficult to parse stumbling around in Python so Kaitai Struct has been amazing. 

However the WebIDE parsed 1300 records in a couple of seconds, but my implementation in Python, using the same data file is taking much longer (it's yet to complete after about 10 minutes) so I feel I must be doing something wrong.

```python
from kaitaistruct import KaitaiStream, BytesIO
from my_onion_parser import Onions #generated using http://kaitai.io/repl/index.html

f = open('dat_0','rb').read()

stream = KaitaiStream(BytesIO(f))

onion_records = Onions(stream)
```
I couldn't find documentation on properly using the python API so I may be making fundamental mistakes here. Current file is about 100MB in binary, but I need to parse around 9Gb eventually and I'm finding it tricky to parse without encountering memory errors.