

- #LESS PROC CPUINFO UPDATE#
- #LESS PROC CPUINFO CODE#
- #LESS PROC CPUINFO FREE#
- #LESS PROC CPUINFO WINDOWS#

Note, the above works as I make the assumption that the file always ends with an empty line. Return any(map(lambda core: core != core, cpuinfo)) Key, value = map(str.strip, line.split(':', 1)) With open('/proc/cpuinfo') as file_handler: Also if you have more than one CPU (say you are using a sever) then you could return false on one CPU and true on another, but as the last core overwrites all the previous data it's somewhat up to chance to know.ĭue to this I would recommend that you change your function to make cpuinfo a list of dicts.įinally as far as I know unless you read the entire file and split on \n\n then there is no way to make it a comprehension.Īnd so I would recommend: def is_hyperthreading_enabled(): So you may not want to overwrite some of this information. This also shows that the information can change. Model name : Intel(R) Core(TM) i5-2500 CPU 3.30GHzĪddress sizes : 36 bits physical, 48 bits virtual Just to note, ':' in line returns false every time the CPU core changes.įor example from my /proc/info. Overall I would recommend using your original code, but with with and line.split(':', 1)) added. Lambda line: map(str.strip, line.split(':', 1)),įilter(lambda line: ':' in line, file_handler) with open('/proc/cpuinfo') as file_handler: Which has the drawback of needing to define line twice, and is more verbose than the original code. You could however use a functional approach to this.
#LESS PROC CPUINFO CODE#
Where dictionary comprehensions were added in 2.7.Īnd your original code is a lot less verbose. This is in my opinion worse than your above code, as it's common knowledge that dict(]) can be used to make a dict, which was added in 2.2. Then it's the same as your above code, but it will have a dictionary comprehension surrounding it. If you want to use a dictionary comprehension at all cost. To avoid this as an issue, you can use the optional second argument to str.split(':', 1).
#LESS PROC CPUINFO UPDATE#
with the exception: ValueError: dictionary update sequence element #1 has length 3 2 is required If a vendor were to put a : in their name, your code won't work. As it seems model name can be whatever the model is called. While /proc/cpuinfo is unlikely to have more than one : per line, it could happen. The second is more recommended as then it's both clear when the file is open, and you don't forget to close it.

The old style way: file_handler = open('/proc/cpuinfo') Other similar apps out there however offer much more than that, so CPUInfo still needs some improvements in this regard.First off, you should always close a file in Python. Overall, CPUInfo is a nice and quick way to get information on your CPU, providing a decent amount of details on this particular piece of hardware.
#LESS PROC CPUINFO WINDOWS#
It’s more or less obvious that CPUInfo doesn’t slow down your computer in any way, working flawlessly regardless of the Windows version running on your system. It addition, it displays other processor details accessible from Windows, including the maximum number of cores, active cores, processor type and level, revision and architecture.Īll these details can be exported to a TXT file, with CPUInfo allowing you to select the categories you wish to be included in the report.
#LESS PROC CPUINFO FREE#
The Windows tab could come in handy to many users out there because it shows the current operating system, service pack and build, total, used and free physical memory and virtual memory. The “Processor Information” tabs shows details on each core of the CPU, such as data concerning the current core speed, revision, vendor ID, CPU name, instructions, cache, feature flags and detailed CPUID. The interface adopted a tabbed layout, with two important sections, processor information and Windows, each with pretty self-intuitive names. The program has been specifically designed with a single goal in mind, to show processor details, so aside from reading some valuable information about this particular hardware component, you can’t do anything else. CPUInfo is a very simple Windows application that can show you information concerning the processor, using a very clean and well-organized interface as a means of communication.
