Change in vdsm[master]: vdsm: introduce cpuinfo module

nsoffer at redhat.com nsoffer at redhat.com
Wed Jan 20 07:43:52 UTC 2016


Nir Soffer has posted comments on this change.

Change subject: vdsm: introduce cpuinfo module
......................................................................


Patch Set 23: Code-Review-1

(1 comment)

The cpuinfo module is extremely nice, but needs a minor class rename. I did not look in the other modules yet.

https://gerrit.ovirt.org/#/c/46912/23/lib/vdsm/cpuinfo.py
File lib/vdsm/cpuinfo.py:

Line 24: from . import cpuarch
Line 25: 
Line 26: 
Line 27: _PATH = '/proc/cpuinfo'
Line 28: _CPU_TEMPLATE = namedtuple('CpuInfo', 'flags, frequency, model')
This creates a class named "CpuInfo", and store it in the name _CPU_TEMPLATE.

This is equivalent to this code:

    class CpuInfo(tuple):
        ...

    _CPU_TEMPLATE = CpuInfo
    del CpuInfo

Can you explain why this is needed?

namedtuple is like a macro, generating a class on the fly. The result is a regular class object, there is no magic here.
See /usr/lib64/python2.7/collections.py

Always use the name of the class for the result of namedtuple.
Line 29: 
Line 30: 
Line 31: @utils.memoized
Line 32: def _cpuinfo():


-- 
To view, visit https://gerrit.ovirt.org/46912
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Iaa702b05f3825ebdcfed16d86d39a8c38fcf224c
Gerrit-PatchSet: 23
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Martin Betak <mbetak at redhat.com>
Gerrit-Reviewer: Martin Polednik <mpolednik at redhat.com>
Gerrit-Reviewer: Michal Skrivanek <mskrivan at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list