From 3d97b70b6a798fc3f2b95412f5857ff0e440a866 Mon Sep 17 00:00:00 2001 From: Balint Csergo Date: Fri, 22 Jul 2022 09:53:50 -0700 Subject: [PATCH] Speed up mock_constructor by removing gc.collect (#335) Summary: Pull Request resolved: https://github.com/facebook/TestSlide/pull/335 mock_aiog 0:00:00.064367 from this calling gc.collect took: 0:00:00.053297 and it's _synchronous_ since default slow callback detection is 0.1 if someone uses multiple mock_constructor calls these gc.collect-s add up and exceed the threshold Reviewed By: doranand Differential Revision: D38073077 fbshipit-source-id: fb1a80905211b058f674c98333075f40e9efcbf3 --- testslide/mock_constructor.py | 1 - 1 file changed, 1 deletion(-) diff --git a/testslide/mock_constructor.py b/testslide/mock_constructor.py index 264ae01..c69919d 100644 --- a/testslide/mock_constructor.py +++ b/testslide/mock_constructor.py @@ -349,7 +349,6 @@ def mock_constructor( "Usage with classes that define __new__() is currently not supported." ) - gc.collect() instances = [ obj for obj in gc.get_referrers(original_class)