Return a set of CPU features that implied by 'names' Parameters ---------- names : str or sequence of str CPU feature name(s) in uppercase. keep_origins : bool if False(default) then the returned set will not contain any
(self, names, keep_origins=False)
| 1346 | return sorted(names, reverse=reverse, key=sort_cb) |
| 1347 | |
| 1348 | def feature_implies(self, names, keep_origins=False): |
| 1349 | """ |
| 1350 | Return a set of CPU features that implied by 'names' |
| 1351 | |
| 1352 | Parameters |
| 1353 | ---------- |
| 1354 | names : str or sequence of str |
| 1355 | CPU feature name(s) in uppercase. |
| 1356 | |
| 1357 | keep_origins : bool |
| 1358 | if False(default) then the returned set will not contain any |
| 1359 | features from 'names'. This case happens only when two features |
| 1360 | imply each other. |
| 1361 | |
| 1362 | Examples |
| 1363 | -------- |
| 1364 | >>> self.feature_implies("SSE3") |
| 1365 | {'SSE', 'SSE2'} |
| 1366 | >>> self.feature_implies("SSE2") |
| 1367 | {'SSE'} |
| 1368 | >>> self.feature_implies("SSE2", keep_origins=True) |
| 1369 | # 'SSE2' found here since 'SSE' and 'SSE2' imply each other |
| 1370 | {'SSE', 'SSE2'} |
| 1371 | """ |
| 1372 | def get_implies(name, _caller=set()): |
| 1373 | implies = set() |
| 1374 | d = self.feature_supported[name] |
| 1375 | for i in d.get("implies", []): |
| 1376 | implies.add(i) |
| 1377 | if i in _caller: |
| 1378 | # infinity recursive guard since |
| 1379 | # features can imply each other |
| 1380 | continue |
| 1381 | _caller.add(name) |
| 1382 | implies = implies.union(get_implies(i, _caller)) |
| 1383 | return implies |
| 1384 | |
| 1385 | if isinstance(names, str): |
| 1386 | implies = get_implies(names) |
| 1387 | names = [names] |
| 1388 | else: |
| 1389 | assert(hasattr(names, "__iter__")) |
| 1390 | implies = set() |
| 1391 | for n in names: |
| 1392 | implies = implies.union(get_implies(n)) |
| 1393 | if not keep_origins: |
| 1394 | implies.difference_update(names) |
| 1395 | return implies |
| 1396 | |
| 1397 | def feature_implies_c(self, names): |
| 1398 | """same as feature_implies() but combining 'names'""" |
no outgoing calls
no test coverage detected