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
Almost half of my pytest collection time is spent inside parameterized.expand, specifically inside inspect.stack. I tried switching to inspect.currentframe and it's significantly faster as it doesn't have to assemble the entire stack just to look at the outer frame.
0.7.5 will fix the issue you called out. There's still one more use that may affect things:
def_terrible_magic_get_defining_classes(self):
""" Returns the set of parent classes of the class currently being defined. Will likely only work if called from the ``parameterized`` decorator. This function is entirely @brandon_rhodes's fault, as he suggested the implementation: http://stackoverflow.com/a/8793684/71522 """stack=inspect.stack()
iflen(stack) <=4:
return []
frame=stack[4]
code_context=frame[4] andframe[4][0].strip()
ifnot (code_contextandcode_context.startswith("class ")):
return []
_, _, parents=code_context.partition("(")
parents, _, _=parents.partition(")")
returneval("["+parents+"]", frame[0].f_globals, frame[0].f_locals)
But this will take a bit more work + testing to fix, so I'm going to hold off until I have the time (and, ofc, I'd love a PR)
Almost half of my pytest collection time is spent inside
parameterized.expand
, specifically insideinspect.stack
. I tried switching toinspect.currentframe
and it's significantly faster as it doesn't have to assemble the entire stack just to look at the outer frame.i.e.
parameterized/parameterized/parameterized.py
Lines 493 to 495 in ff5a1da
to
The text was updated successfully, but these errors were encountered: