MCPcopy Index your code
hub / github.com/python/cpython / TupleComp

Class TupleComp

Lib/pstats.py:556–575  ·  view source on GitHub ↗

This class provides a generic function for comparing any two tuples. Each instance records a list of tuple-indices (from most significant to least significant), and sort direction (ascending or descending) for each tuple-index. The compare functions can then be used as the function

Source from the content-addressed store, hash-verified

554
555
556class TupleComp:
557 """This class provides a generic function for comparing any two tuples.
558 Each instance records a list of tuple-indices (from most significant
559 to least significant), and sort direction (ascending or descending) for
560 each tuple-index. The compare functions can then be used as the function
561 argument to the system sort() function when a list of tuples need to be
562 sorted in the instances order."""
563
564 def __init__(self, comp_select_list):
565 self.comp_select_list = comp_select_list
566
567 def compare (self, left, right):
568 for index, direction in self.comp_select_list:
569 l = left[index]
570 r = right[index]
571 if l < r:
572 return -direction
573 if l > r:
574 return direction
575 return 0
576
577
578#**************************************************************************

Callers 1

sort_statsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…