Bug report
What's wrong
Open a REPL, create not-so-huge amount of providers:
>>> a = [mimesis.Business() for _ in range(10000)]
Not examine memory footprint of the process: in my case it's 1,1g.
How is that should be
Why would I need so many providers? I never knew they're such heavy objects, I was using them naively in tests:
@pytest.fixture
def user_factory():
mgen = mimesis.Person()
async def user_factory():
name = mgen.name()
...
return user_factory
Seems like pytest keeps references to each fixture value, even if the test has finished. In our case it's closure with mimesis provider. For each test we create a provider or several of them. This leads to huge memory consumption of test suite.
I agree that correct use would be
@pytest.fixture(scope='session')
def mimesis_person_gen():
return mimesis.Person()
@pytest.fixture
def user_factory(mimesis_person_gen):
...
this fixes memory consumption issue. But there's no any mention in documentation that provider objects are that heavy and one should construct them as few as possible. Probably issuing a warning on constructing 1000th provider would help many people who try to find out why their tests consume so much memory.
Bug report
What's wrong
Open a REPL, create not-so-huge amount of providers:
Not examine memory footprint of the process: in my case it's 1,1g.
How is that should be
Why would I need so many providers? I never knew they're such heavy objects, I was using them naively in tests:
Seems like pytest keeps references to each fixture value, even if the test has finished. In our case it's closure with mimesis provider. For each test we create a provider or several of them. This leads to huge memory consumption of test suite.
I agree that correct use would be
this fixes memory consumption issue. But there's no any mention in documentation that provider objects are that heavy and one should construct them as few as possible. Probably issuing a warning on constructing 1000th provider would help many people who try to find out why their tests consume so much memory.