Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow parsing of huge (26k+ lines) python files #103

Open
Hi-Angel opened this issue Feb 5, 2023 · 2 comments
Open

Slow parsing of huge (26k+ lines) python files #103

Hi-Angel opened this issue Feb 5, 2023 · 2 comments

Comments

@Hi-Angel
Copy link
Collaborator

Hi-Angel commented Feb 5, 2023

Steps to reproduce

  1. Get a python file wget https://raw.githubusercontent.com/qutebrowser/qutebrowser/master/qutebrowser/browser/browsertab.py
  2. Make a 1.py file that is twenty times larger: for i in $(seq 1 20); do cat browsertab.py >> 1.py; done
  3. Open the 1.py file
  4. Evaluate (benchmark-run 1 (color-identifiers:list-identifiers))

Expected

0.2 or 0.3 seconds

Actual

1.4 seconds

Additional information

benchmark-report says that 70% of time is spent in internal Emacs function we call (sexp-at-point).

So one solution to this problem could be optimizing this function.

Another good idea might be to modify upstream python-mode so that they mark args inside defuns with a font-lock-variable-name-face face, which would allow to get rid of color-identifiers:python-get-declarations in preference of the generic color-identifiers:get-declarations (well, maybe not completely, but at least for Emacs versions that will support that feature)

Hi-Angel added a commit to Hi-Angel/color-identifiers-mode that referenced this issue Feb 5, 2023
Do it by interrupting parsing if user is trying to do something.

See also: ankurdave#103
Hi-Angel added a commit that referenced this issue Feb 5, 2023
Do it by interrupting parsing if user is trying to do something.

See also: #103
@Hi-Angel
Copy link
Collaborator Author

Hi-Angel commented Feb 5, 2023

I added a commit that interrupts parsing if a user becomes active, so from a user POV that problem doesn't really exists anymore. At this point it is more of a developer interest, e.g. for refactoring etc.

@Hi-Angel Hi-Angel changed the title Slow parsing of huge (20k+ lines) python files Slow parsing of huge (26k+ lines) python files Feb 5, 2023
@Hi-Angel
Copy link
Collaborator Author

Hi-Angel commented Feb 5, 2023

upd: changed the title to match up the timings in "steps-to-reproduce".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant