-
Notifications
You must be signed in to change notification settings - Fork 13
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
Avoid imports inside functions #60
Avoid imports inside functions #60
Conversation
Codecov Report
@@ Coverage Diff @@
## master #60 +/- ##
===========================================
+ Coverage 99.62% 100.00% +0.37%
===========================================
Files 3 4 +1
Lines 266 285 +19
===========================================
+ Hits 265 285 +20
+ Misses 1 0 -1
Continue to review full report at Codecov.
|
(did not check the performance change, though) |
Performance-wise, it is 16.5 times slower than it used to be in 3bc56f2 (the commit I happen to have in the main branch of my fork), but 29 times faster than it currently is. The speed up is amazing, although I wonder whether or not it warrants closing #59, given the performance difference with 3bc56f2 (which is probably explained by support for new item types, I did not check what that commit supported and did not support). from timeit import timeit
from itemadapter import is_item
def a():
return is_item({})
print(timeit(a, number=1000000)) 3bc56f2: 0.08102401599990117 |
That's awesome, thanks! I just pushed eee23cf, which improves performance greatly by removing unnecessary duplicated calls to get Scrapy item classes, that was also being done on each item check. Two additional things that are improving performance for me:
|
Re fdf1339, seems to me like the extra access to the |
Related to #59 (not sure if it fixes it completely)
Tasks:
sys.modules
if they were imported already)itemadapter.adapter