Last active
April 29, 2018 19:39
-
-
Save kaidokert/28837f8bc9c181fe28f2e8bcf0dcdde1 to your computer and use it in GitHub Desktop.
Tracing excessive callers to re.compile in re.py
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
callers = {} | |
def _ghetto_compile(pattern, flags=0): | |
import inspect | |
try: | |
frame = '{}'.format(inspect.currentframe().f_back.f_code) | |
val = callers.setdefault(frame,0) | |
callers[frame] = val + 1 | |
# print(frame) | |
if 'rest_framework.py' in frame: | |
pass | |
#print(sorted(callers.iteritems(),key=lambda (k,v):(v,k),reverse=True)) | |
except Exception as e: | |
print('fail {}'.format(e) ) | |
"Compile a regular expression pattern, returning a pattern object." | |
return _compile(pattern, flags) | |
def compile(pattern, flags=0): | |
"Compile a regular expression pattern, returning a pattern object." | |
return _compile(pattern, flags) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment