Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork939
Commitd70ba69
committed
Extract all "import gc" to module level
The gc module was already imported at module scope ingit/repo/base.py, sincef1a82e4 (#555). Importing the top-levelgit module or any submodule of it runs that import statement.Because the gc module is already imported, reimporting it is fast.Imports that there is no specific reason to do locally should be atmodule scope. Having them local decreased readability, in partbecause of how black inserts a black line between them andgc.collect() calls they are imported to allow.An alternative to this change would be to remove the preexistingtop-level "import gc" (there is also another one in the test suite)and replace it with a local import as well. I am unsure if thatwould affect performance and, if so, whether the effect would begood or bad, since the small delay of the import might potentiallybe less desirable to an applicaion if it occurs while the work ofthe application is already in progress.If a gc.collect() call runs as a consequence of a finally block or__del__ method being called during interpreter shutdown, then in(very) rare cases the variable may have been set to None. But thisdoes not appear to have been the intent behind making the importslocal. More importantly, a local import should not be expected tosucceed, or the imported module usable, in such a situation.1 parent68272aa commitd70ba69
File tree
10 files changed
+11
-20
lines changed- git/objects/submodule
- test
- performance
10 files changed
+11
-20
lines changedLines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | 2 |
| |
3 | 3 |
| |
| 4 | + | |
4 | 5 |
| |
5 | 6 |
| |
6 | 7 |
| |
| |||
1079 | 1080 |
| |
1080 | 1081 |
| |
1081 | 1082 |
| |
1082 |
| - | |
1083 |
| - | |
1084 | 1083 |
| |
1085 | 1084 |
| |
1086 | 1085 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5 | 5 |
| |
6 | 6 |
| |
7 | 7 |
| |
| 8 | + | |
8 | 9 |
| |
9 | 10 |
| |
10 | 11 |
| |
| |||
17 | 18 |
| |
18 | 19 |
| |
19 | 20 |
| |
20 |
| - | |
21 |
| - | |
22 | 21 |
| |
23 | 22 |
| |
24 | 23 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
| 6 | + | |
6 | 7 |
| |
7 | 8 |
| |
8 | 9 |
| |
| |||
92 | 93 |
| |
93 | 94 |
| |
94 | 95 |
| |
95 |
| - | |
96 |
| - | |
97 | 96 |
| |
98 | 97 |
| |
99 | 98 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
| 6 | + | |
6 | 7 |
| |
7 | 8 |
| |
8 | 9 |
| |
| |||
20 | 21 |
| |
21 | 22 |
| |
22 | 23 |
| |
23 |
| - | |
24 |
| - | |
25 | 24 |
| |
26 | 25 |
| |
27 | 26 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
| 6 | + | |
6 | 7 |
| |
7 | 8 |
| |
8 | 9 |
| |
| |||
16 | 17 |
| |
17 | 18 |
| |
18 | 19 |
| |
19 |
| - | |
20 |
| - | |
21 | 20 |
| |
22 | 21 |
| |
23 | 22 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
| 6 | + | |
6 | 7 |
| |
7 | 8 |
| |
8 | 9 |
| |
| |||
34 | 35 |
| |
35 | 36 |
| |
36 | 37 |
| |
37 |
| - | |
38 |
| - | |
39 | 38 |
| |
40 | 39 |
| |
41 | 40 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | 2 |
| |
3 | 3 |
| |
| 4 | + | |
| 5 | + | |
4 | 6 |
| |
5 | 7 |
| |
6 | 8 |
| |
7 | 9 |
| |
8 | 10 |
| |
9 | 11 |
| |
10 |
| - | |
11 |
| - | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
| 6 | + | |
6 | 7 |
| |
7 | 8 |
| |
8 | 9 |
| |
| |||
105 | 106 |
| |
106 | 107 |
| |
107 | 108 |
| |
108 |
| - | |
109 |
| - | |
110 | 109 |
| |
111 | 110 |
| |
112 | 111 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
| 6 | + | |
6 | 7 |
| |
7 | 8 |
| |
8 | 9 |
| |
| |||
72 | 73 |
| |
73 | 74 |
| |
74 | 75 |
| |
75 |
| - | |
76 |
| - | |
77 | 76 |
| |
78 | 77 |
| |
79 | 78 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2 | 2 |
| |
3 | 3 |
| |
4 | 4 |
| |
| 5 | + | |
5 | 6 |
| |
6 | 7 |
| |
7 | 8 |
| |
| |||
61 | 62 |
| |
62 | 63 |
| |
63 | 64 |
| |
64 |
| - | |
65 |
| - | |
66 | 65 |
| |
67 | 66 |
| |
68 | 67 |
| |
|
0 commit comments
Comments
(0)