[Python-Dev] Reduce memory footprint of Python

Olemis Lang olemis at gmail.com
Sun Oct 6 23:56:57 CEST 2013


On 10/6/13, Benjamin Peterson <benjamin at python.org> wrote:
> 2013/10/6 Victor Stinner <victor.stinner at gmail.com>:
>> Hi,
>>

:)

[...]
>>
>> unittest doesn't look to release memory (the TestCase class) after the
>> execution of a test.
>
> Is it important to optimize unittests for memory usage?
>

AFAICT , test results will stored the outcomes of individual test
cases , which is O(n) under normal circumstances, but I guess this is
not what Victor was talking about (isn't it ?).

However , I've been thinking since some time ago that if the only
outcome of running the test suite is to dump the output to stdout or
any other file-like object then test result lists might be of little
value most of the time . Maybe an efficient runner + results
implementation focused on streaming output with no caching could help
with efficient memory allocations .

Regarding the memory allocated in setUp* method(s) then IMO it should
be torn down if it will not be used anymore. Such optimizations should
be better performed in TCs tearDown* methods themselves rather than
e.g. automatically deallocating memory associated to TC instances .
Sometimes different tools use such data for certain analysis .

<jftr>
BTW , I've detected a few instances where this proves to be useful (to
me) ; especially (concurrently) running (matrix jobs of) relatively
long test suites on hosted (Jenkins) instances , where quotas apply .
</jftr>

-- 
Regards,

Olemis - @olemislc

Apache™ Bloodhound contributor
http://issues.apache.org/bloodhound
http://blood-hound.net

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Popularidad de Python, septiembre 2013 -
http://goo.gl/fb/tr0XB


More information about the Python-Dev mailing list