You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
7 MB from build_ranked_dict.<locals>.<dictcomp> while importing site-packages/zxcvbn/matching.py:10
matching.py imports frequency_lists and processes them into RANKED_DICTIONARIES which causes the extra usage
I'm not necessarily suggesting that the behaviour of this package be changed, though I guess it would be possible to make the import very cheap and lazily do all the above effort only the first time it is required.
In the mean time though, I could easily get an equivalent benefit by moving my import of zxcvbn to happen only inside the request handler which needs it, so that most of the python processes handling requests didn't need to bother, unless they received a request involving a user attempting to set a password.
The text was updated successfully, but these errors were encountered:
sparrowt
changed the title
Awareness about memory consumption
Memory usage awareness: recommend late import
Oct 20, 2023
While profiling memory usage I noticed that importing
zxcvbn
was causing ~12mb of memory allocation:This is not necessarily surprising but I thought I'd mention it here in case there was any obvious way to reduce it.
According to the profiling there was:
site-packages/zxcvbn/frequency_lists.py:4
build_ranked_dict.<locals>.<dictcomp>
while importingsite-packages/zxcvbn/matching.py:10
RANKED_DICTIONARIES
which causes the extra usageI'm not necessarily suggesting that the behaviour of this package be changed, though I guess it would be possible to make the import very cheap and lazily do all the above effort only the first time it is required.
In the mean time though, I could easily get an equivalent benefit by moving my import of
zxcvbn
to happen only inside the request handler which needs it, so that most of the python processes handling requests didn't need to bother, unless they received a request involving a user attempting to set a password.The text was updated successfully, but these errors were encountered: