<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>zehnpaard</author_name>
  <author_url>https://blog.hatena.ne.jp/zehnpaard/</author_url>
  <blog_title>Arantium Maestum</blog_title>
  <blog_url>https://zehnpaard.hatenablog.com/</blog_url>
  <categories>
    <anon>Python</anon>
    <anon>言語処理系</anon>
  </categories>
  <description>前回まで見てきたBacktrackingパーサ、Packratパーサは「これまで見たすべてのトークン」をメモリ上のバッファに保持し続け、それらに対してのパース結果もすべてキャッシュに残し続ける実装になっていて、パース終了直前にはソースファイルのすべてのトークンがメモリに乗っている状態になってしまう。 実際にはバックトラックする予定がない場合、現在地以前にあるバッファのトークンを消してしまってもなんの問題もないし、それに対応するパース関数のキャッシュも削除できる。今回はその修正の話。 計測 まずparse関数をいじってパース終了時にtokens.bufferをプリントするようにする： def p…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fzehnpaard.hatenablog.com%2Fentry%2F2021%2F09%2F17%2F110944&quot; title=&quot;PythonでLanguage Implementation Patternsのパーサと戯れる　Packratパーサのメモリ効率化 - Arantium Maestum&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2021-09-17 11:09:44</published>
  <title>PythonでLanguage Implementation Patternsのパーサと戯れる　Packratパーサのメモリ効率化</title>
  <type>rich</type>
  <url>https://zehnpaard.hatenablog.com/entry/2021/09/17/110944</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
