In IDLE colorizer, replace re with tokenizer
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
The current IDLE colorizer was designed when the python grammar was restricted to a context-free subtype. Parsing with RE's was sufficient or closely so to pick out substrings to be color tagged. The current grammar's sometime context-dependence make this more difficult or even impossible.
A few versions ago, the new C tokenizer used to compile Python code was exposed as a function in the tokenizer module. It replaced a python-coded tokenizer that did not always match the old C tokenizer and that must have been much slower. I assume that is was not seen as suitable for IDLE colorizer. However, the current exposed C tokenizer is being used to power the new PyREPL colorizer. The initial (draft) patch copies portions of that colorizer.
My main concerns are compatibility and speed. Some initial questions:
- The syntax categories in the REPL colorizer are not the same as IDLE's (listed on the Highlights settings page). What are they?
- IDLE colorizes 10000 lines editor contents as well as single interactive lines. Will the PR colorizer do the same, with similar speed?
- Is REPL colorizer stable? Are there open bug reports? (Should be labelled
topic-repl.) The code is private and undocumented, I presume intentionally, and I do not expect that issues only relevant to IDLE would be welcome. - In the IDLE Issues project, colorizer issues are in Highlights section. Does this fix any, or appear to make fixes easier?
Linked PRs
- gh-140337
- gh-152756
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing IDLE's current regex-based colorizer with the tokenizer-backed PyREPL colorizer and the exposed tokenizer module. Review the linked PRs gh-140337 and gh-152756, then assess syntax-category compatibility, 10,000-line editor performance, REPL colorizer stability, and relevance to the IDLE Highlights issues.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100