mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2025-07-30 23:41:52 +03:00
examples/topology: define socketIds and siblingsIds as sets
socketIds and siblingsIds are declared as empty lists, filled by list comprehensions, and later on re-used as sets. They could be directly obtained from set comprehensions. Fixes:34aa32b
("Move python example programs into python/examples/ subdirectory") Fixes:3f4e32c
("examples: Invoke print("...") instead of print "..."") Link: https://docs.python.org/3/tutorial/datastructures.html#sets Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
committed by
Michal Prívozník
parent
cbcafe129b
commit
a66fcfaf2b
@ -26,23 +26,18 @@ host = caps.getElementsByTagName('host')[0]
|
||||
cells = host.getElementsByTagName('cells')[0]
|
||||
total_cpus = cells.getElementsByTagName('cpu').length
|
||||
|
||||
socketIds = []
|
||||
siblingsIds = []
|
||||
|
||||
socketIds = [
|
||||
socketIds = {
|
||||
proc.getAttribute('socket_id')
|
||||
for proc in cells.getElementsByTagName('cpu')
|
||||
if proc.getAttribute('socket_id') not in socketIds
|
||||
]
|
||||
}
|
||||
|
||||
siblingsIds = [
|
||||
siblingsIds = {
|
||||
proc.getAttribute('siblings')
|
||||
for proc in cells.getElementsByTagName('cpu')
|
||||
if proc.getAttribute('siblings') not in siblingsIds
|
||||
]
|
||||
}
|
||||
|
||||
print("Host topology")
|
||||
print("NUMA nodes:", cells.getAttribute('num'))
|
||||
print(" Sockets:", len(set(socketIds)))
|
||||
print(" Cores:", len(set(siblingsIds)))
|
||||
print(" Sockets:", len(socketIds))
|
||||
print(" Cores:", len(siblingsIds))
|
||||
print(" Threads:", total_cpus)
|
||||
|
Reference in New Issue
Block a user