Skip to content
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

RecursionError for deepcopy with 400x400 matching task #139

Open
james016 opened this issue Jun 10, 2022 · 2 comments
Open

RecursionError for deepcopy with 400x400 matching task #139

james016 opened this issue Jun 10, 2022 · 2 comments
Labels

Comments

@james016
Copy link

I bumped into RecursionError in the deepcopy reproduced by

import sys
from matching.games import StableMarriage

# fix by enlarging the size of recursionlimit
# sys.setrecursionlimit(10000)

num_x = 400
num_y = 400

x2y = {x:list(range(num_y)) for x in range(num_x)}
y2x = x2y

game = StableMarriage.create_from_dictionaries(x2y, y2x)

It cased by the deepcopy of players.
By setting recursionlimit to a higher value can reduce the problem in this case with 400x400 matching task, I found. But it may be not reduced fundamentally.

@daffidwilde
Copy link
Owner

Hi @james016. Thanks for raising this. That is certainly annoying but the call to copy.deepcopy() is pretty integral to how the players get created and adjusted.

I will try to set aside some time to think about an alternative solution but, for now, I think your workaround will have to do. I don't know if I'm comfortable making global changes to the system recursion limit as part of matching.

Sorry to disappoint and thanks again for opening this up.

@obscurerichard
Copy link

I stumbled on this issue and explored a bit more about the Python recursion limit and found a StackOverflow answer giving an elegant way of wrapping the setting of recursionlimit using with. The article has a bunch of other interesting advice and solutions regarding deep recursion in Python too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants