[Python-ideas] unicodedata.itergraphemes (or str.itergraphemes / str.graphemes)
Joshua Landau
joshua at landau.ws
Wed Jul 10 20:08:37 CEST 2013
On 10 July 2013 18:39, Philipp A. <flying-sheep at web.de> wrote:
> 2013/7/10 Joshua Landau joshua at landau.ws
>
>>>> {}.keys()
> dict_keys([])
>>>> iter({}.keys())
> <dict_keyiterator object at 0x7fe3d633a890>
>
> There are good reasons why a “view” should not be its iterator.
>
> you’re right, but one would expect the view’s __getitem__(i) method to
> return the ith 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.
>
> so should we do a view object that only allows something like my
> find_grapheme and iteration?
I haven't followed much of this because it's not very relevant to me
now. I just thought it extremely odd to have an interface inconsistent
with Python's standard.
However, if what you want is something that works akin to a IOWrapper,
then I'm wrong and an iterator that has lots of methods is actually
already standard. Hence I've changed my mind.
That may not have been what you expected me to say.
More information about the Python-ideas
mailing list