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

* layers/+lang/python/funcs.el: Rewrite spacemacs/pyenv-executable-find to support list #16819

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

sunlin7
Copy link
Contributor

@sunlin7 sunlin7 commented Feb 5, 2025

Rewrite the function spacemacs/pyenv-executable-find for better performance.
Original function will invoke the '/bin/pyenv' twice to determine one command; then it has 24 invokes for the /bin/pyenv triggered by the function spacemacs/python-toggle-breakpoint on my local, with this patch the calls will reduce to 8.
Please help review the changes, thanks

Copy link
Collaborator

@bcc32 bcc32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for this contribution.

(setq i (1+ i))))
executable))
(executable-find command)))
(defun spacemacs/pyenv-executable-find (commands)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function might be called in user configs. It would be nicer if it continued to accept a single command and treated it as a singleton list, for backwards compatibility.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would also avoid some unnecessary changes in this same file.

(defun spacemacs/pyenv-executable-find (commands)
"Find executable taking pyenv shims into account. If the pyenv was
configured with \"system\" then the system exectutable will be included,
otherwise the system executable will be ignored."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add documentation about how the function handles the commands argument? Specifically, it's important to note that it will return some path corresponding to some command (the first one that appears in the list?)

(thing-at-point 'line))))
(line (thing-at-point 'line)))
(let* ((exe (spacemacs/pyenv-executable-find '("trepan3k" "wdb" "ipdb3" "pudb3" "ipdb" "pudb" "python3")))
(trace (pcase (file-name-nondirectory (or exe ""))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: (and exe (file-name-nondirectory exe)) would be more elegant here, IMO (avoid unnecessarily calling the function file-name-nondirectory).

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

Successfully merging this pull request may close these issues.

2 participants