Changeset 153:a8b8beb4b0dd
- Timestamp:
- 08/05/10 09:59:08 (21 months ago)
- Author:
- Menno Smits <menno@…>
- Branch:
- default
- Message:
-
Speedups: avoid initialising constants in init, use frozenset instead of set
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r152
|
r153
|
|
| 40 | 40 | SPECIALS = r' ()%"' + CTRL_CHARS |
| 41 | 41 | ALL_CHARS = [chr(ch) for ch in range(256)] |
| 42 | | NON_SPECIALS = [ch for ch in ALL_CHARS if ch not in SPECIALS] |
| | 42 | NON_SPECIALS = frozenset([ch for ch in ALL_CHARS if ch not in SPECIALS]) |
| | 43 | WHITESPACE = frozenset(' \t\r\n') |
| 43 | 44 | |
| 44 | 45 | def __init__(self): |
| 45 | | self.wordchars = set(self.NON_SPECIALS) |
| 46 | | self.whitespace = set((' \t\r\n')) |
| 47 | 46 | self.sources = None |
| 48 | 47 | self.current_source = None |
| … |
… |
|
| 68 | 67 | |
| 69 | 68 | def read_token_stream(self, stream_i): |
| 70 | | whitespace = self.whitespace |
| 71 | | wordchars = self.wordchars |
| | 69 | whitespace = self.WHITESPACE |
| | 70 | wordchars = self.NON_SPECIALS |
| 72 | 71 | parse_quote = self.parse_quote |
| 73 | 72 | |