<div dir="ltr"><div style class="markdown-here-wrapper" id="markdown-here-wrapper-377556"><p style="margin:1.2em 0px!important">2013/7/10 Joshua Landau <a href="mailto:joshua@landau.ws">joshua@landau.ws</a></p>
<blockquote style="margin:1.2em 0px;border-left:4px solid rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none">
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px 3px 3px 3px;display:inline;white-space:pre;overflow:auto;border-radius:3px 3px 3px 3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block;padding:0.5em;color:rgb(51,51,51);background:none repeat scroll 0% 0% rgb(248,248,255)" class="language-python">>>> {}.keys()
dict_keys([])
>>> iter({}.keys())
<dict_keyiterator object at <span style="color:rgb(0,153,153)" class="number">0x7fe3d633a890</span>></code></pre>
<p style="margin:1.2em 0px!important">There are good reasons why a “view” should not be its iterator.</p>
</blockquote>
<p style="margin:1.2em 0px!important">you’re right, but one would expect the view’s <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px 3px 3px 3px;display:inline">__getitem__(i)</code> method to return the <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px 3px 3px 3px;display:inline">i</code>th grapheme, which implies constant-time access. and we can only support linear-time access to that (i.e. by iterating stuff) if we don’t want to build a complex index.</p>

<p style="margin:1.2em 0px!important">so should we do a view object that only allows something like my <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px 3px 3px 3px;display:inline">find_grapheme</code> and iteration?</p>

</div></div>