Commit 24f4600
authored
Remove LRU cache from methods [ruff rule cached-instance-method] (#13306)
Enables ruff rule cached-instance-method (B019).
By caching instance methods, the instances are kept alive until they are
evicted out of the LRU cache. If the cached instance is itself is
referencing other memory-heavy objects, this can lead to hard-to-debug
high memory usage.
Most of the objects fixed here are fairly long lived, but we don't
necessarily want them to be kept alive until the very end of the process.
Hypothetically, if the build isolation became in-process there will be
multiple instances of these classes that should only live for the
lifetime of any particular build isolation.1 parent d852ebd commit 24f4600
File tree
5 files changed
+54
-14
lines changed- src/pip/_internal
- index
- resolution/resolvelib
- tests/unit
5 files changed
+54
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
170 | 169 | | |
171 | 170 | | |
172 | 171 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
10 | 20 | | |
11 | 21 | | |
12 | 22 | | |
| |||
601 | 611 | | |
602 | 612 | | |
603 | 613 | | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
604 | 621 | | |
605 | 622 | | |
606 | 623 | | |
| |||
795 | 812 | | |
796 | 813 | | |
797 | 814 | | |
798 | | - | |
799 | 815 | | |
800 | 816 | | |
801 | 817 | | |
| |||
805 | 821 | | |
806 | 822 | | |
807 | 823 | | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
808 | 827 | | |
809 | 828 | | |
810 | 829 | | |
| |||
846 | 865 | | |
847 | 866 | | |
848 | 867 | | |
849 | | - | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
850 | 871 | | |
851 | 872 | | |
852 | 873 | | |
| |||
865 | 886 | | |
866 | 887 | | |
867 | 888 | | |
868 | | - | |
869 | 889 | | |
870 | 890 | | |
871 | 891 | | |
| |||
880 | 900 | | |
881 | 901 | | |
882 | 902 | | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
883 | 906 | | |
884 | 907 | | |
885 | 908 | | |
886 | 909 | | |
887 | 910 | | |
888 | 911 | | |
889 | | - | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
890 | 917 | | |
891 | 918 | | |
892 | 919 | | |
| |||
897 | 924 | | |
898 | 925 | | |
899 | 926 | | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
900 | 930 | | |
901 | 931 | | |
902 | | - | |
| 932 | + | |
903 | 933 | | |
904 | 934 | | |
905 | 935 | | |
| |||
Lines changed: 8 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
129 | 128 | | |
130 | 129 | | |
131 | 130 | | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
156 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
157 | 159 | | |
| 160 | + | |
158 | 161 | | |
159 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
| 273 | + | |
273 | 274 | | |
274 | | - | |
| 275 | + | |
275 | 276 | | |
276 | 277 | | |
277 | 278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
319 | 319 | | |
320 | 320 | | |
321 | 321 | | |
322 | | - | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
323 | 326 | | |
324 | 327 | | |
325 | 328 | | |
| |||
335 | 338 | | |
336 | 339 | | |
337 | 340 | | |
| 341 | + | |
| 342 | + | |
338 | 343 | | |
339 | 344 | | |
340 | | - | |
| 345 | + | |
341 | 346 | | |
342 | 347 | | |
343 | 348 | | |
| |||
349 | 354 | | |
350 | 355 | | |
351 | 356 | | |
352 | | - | |
| 357 | + | |
353 | 358 | | |
354 | 359 | | |
355 | 360 | | |
| |||
0 commit comments