News for hackers. Stuff that matters.
Re:Show HN: hazelnut – A pythonic library to parse /proc/mem... by Goopplesoft on Saturday March 12, 2016 @07:37PM (#11275508)
The API of this lib is probably surprising for the typical use-cases because a MemInfo object only represents a path and not a reading/snapshot of the file (each subsequent call to get() re-reads the meminfo file).

> https://github.com/mrsmn/hazelnut/blob/master/hazelnut/core....

So usage like:

   snap_pre = MemInfo()
   # Do stuff here
   snap_post = MemInfo()
   snap_pre.get('Mem')
   snap_post.get('Mem')
   snap_post.get('Mem')
   # All three would likely give different values. 
I would suggest caching the read on instantiation or making them top level functions instead of using a class or MemInfoPath()?

There are no comments on this comment yet.