-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PERF: Help the specializing adpative interpreter (#1522)
This PR aims at making minor changes that do not influence readability in a negative way and help (a tiny bit) to make pypdf faster. https://pypi.org/project/specialist/ was used. ## Specialized instructions You can see the specialized instructions with the `dis` module: ```python python Python 3.11.0 (main, Oct 29 2022, 16:38:13) [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import dis >>> your_function = lambda n: n * 1.5 >>> dis.dis(your_function, adaptive=True) 1 0 RESUME 0 2 LOAD_FAST 0 (n) 4 LOAD_CONST 1 (1.5) 6 BINARY_OP 5 (*) 10 RETURN_VALUE >>> your_function(1.5) 2.25 >>> your_function(2.5) 3.75 >>> your_function(3.5) 5.25 >>> your_function(4.5) 6.75 >>> your_function(5.5) 8.25 >>> your_function(6.5) 9.75 >>> your_function(7.5) 11.25 >>> your_function(8.5) 12.75 >>> your_function(9.5) 14.25 >>> dis.dis(your_function, adaptive=True) 1 0 RESUME_QUICK 0 2 LOAD_FAST__LOAD_CONST 0 (n) 4 LOAD_CONST 1 (1.5) 6 BINARY_OP_MULTIPLY_FLOAT 5 (*) 10 RETURN_VALUE ``` * `BINARY_OP_MULTIPLY_FLOAT`: Multiplying two integers * `BINARY_OP_MULTIPLY_INT`: Multiplying two floats ## See also * https://peps.python.org/pep-0659/ * https://talkpython.fm/episodes/show/381/python-perf-specializing-adaptive-interpreter * https://realpython.com/lessons/faster-faster-faster/ * https://www.andy-pearce.com/blog/posts/2022/Dec/whats-new-in-python-311-performance-improvements/
- Loading branch information
1 parent
82f9c1e
commit 6407e1d
Showing
7 changed files
with
14 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters