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
This is a little niche, so IDK if this is totally needed.
If I run pytest --collect-only --doctest-modules --full-trace on https://github.com/NickCrews/mismo, then pytest goes through all the modules of mismo, and runs doctest on them. As part of that, doctest has to discover all the items in the module. As part of that process, it calls inspect.unwrap() on all the modules variables. That function looks like
defunwrap(func, *, stop=None):
"""Get the object wrapped by *func*. Follows the chain of :attr:`__wrapped__` attributes returning the last object in the chain. *stop* is an optional callback accepting an object in the wrapper chain as its sole argument that allows the unwrapping to be terminated early if the callback returns a true value. If the callback never returns a true value, the last object in the chain is returned as usual. For example, :func:`signature` uses this to stop unwrapping if any object in the chain has a ``__signature__`` attribute defined. :exc:`ValueError` is raised if a cycle is encountered. """ifstopisNone:
def_is_wrapper(f):
returnhasattr(f, '__wrapped__')
else:
def_is_wrapper(f):
returnhasattr(f, '__wrapped__') andnotstop(f)
f=func# remember the original func for error reporting# Memoise by id to tolerate non-hashable objects, but store objects to# ensure they aren't destroyed, which would allow their IDs to be reused.memo= {id(f): f}
recursion_limit=sys.getrecursionlimit()
while_is_wrapper(func):
func=func.__wrapped__id_func=id(func)
if (id_funcinmemo) or (len(memo) >=recursion_limit):
raiseValueError('wrapper loop when unwrapping {!r}'.format(f))
memo[id_func] =funcreturnfunc
So what happens when we call inspect.unwrap() on a Deferred is we recurse infinitely trying to get the __wrapped__ attribute until we hit the recursion limit.
It turns out that in mismo, where I have 30 modules that do an from ibis import _ at the top level, this actually adds up to an appreciable amount of time when collecting tests.
Is your feature request related to a problem?
This is a little niche, so IDK if this is totally needed.
If I run
pytest --collect-only --doctest-modules --full-trace
on https://github.com/NickCrews/mismo, then pytest goes through all the modules of mismo, and runs doctest on them. As part of that, doctest has to discover all the items in the module. As part of that process, it callsinspect.unwrap()
on all the modules variables. That function looks likeSo what happens when we call
inspect.unwrap()
on a Deferred is we recurse infinitely trying to get the__wrapped__
attribute until we hit the recursion limit.It turns out that in mismo, where I have 30 modules that do an
from ibis import _
at the top level, this actually adds up to an appreciable amount of time when collecting tests.What is the motivation behind your request?
Faster tests
Describe the solution you'd like
#10888
What version of ibis are you running?
10.0.0
What backend(s) are you using, if any?
NA
Code of Conduct
The text was updated successfully, but these errors were encountered: