[Python-Dev] Internal representation of strings and Micropython (original) (raw)
Serhiy Storchaka storchaka at gmail.com
Wed Jun 4 19:52:14 CEST 2014
- Previous message: [Python-Dev] Internal representation of strings and Micropython
- Next message: [Python-Dev] Internal representation of strings and Micropython
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
04.06.14 20:05, Paul Sokolovsky написав(ла):
On Wed, 04 Jun 2014 19:49:18 +0300 Serhiy Storchaka <storchaka at gmail.com> wrote:
html.HTMLParser, json.JSONDecoder, re.compile, tokenize.tokenize don't use iterators. They use indices, str.find and/or regular expressions. Common use case is quickly find substring starting from current position using str.find or re.search, process found token, advance position and repeat. That's sad, I agree.
Other languages (Go, Rust) can be happy without O(1) indexing of strings. All string and regex operations work with iterators or cursors, and I believe this approach is not significant worse than implementing strings as O(1)-indexable arrays of characters (for some applications it can be worse, for other it can be better). But Python is different language, it has different operations for strings and different idioms. A language which doesn't support O(1) indexing is not Python, it is only Python-like language.
- Previous message: [Python-Dev] Internal representation of strings and Micropython
- Next message: [Python-Dev] Internal representation of strings and Micropython
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]