[Libre-soc-bugs] [Bug 438] add caching/memoization to soc.simulator.program.Program

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Fri Jul 24 13:07:59 BST 2020


--- Comment #5 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
(In reply to Jacob Lifshay from comment #0)

> Importantly: it needs to *NOT* keep a file open for every Program instance.

this is sorted by using the "with" pattern.  the "with" pattern calls
__enter__ and __exit__.  in Program.__exit__ self.close() is called.

because this had been used:

     x = Program()

the close function was not being called.  it should have been:

     x = Program()

however the whole purpose of "with" is to avoid that extra line and
avoid polluting code with entry/exit gunk.

hence the change to:

      with Program() as x:

and the problem is now gone.

You are receiving this mail because:
You are on the CC list for the bug.

More information about the libre-soc-bugs mailing list