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

Function _compare

Lib/ast.py:432–453  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

430 sentinel = object() # handle the possibility of a missing attribute/field
431
432 def _compare(a, b):
433 # Compare two fields on an AST object, which may themselves be
434 # AST objects, lists of AST objects, or primitive ASDL types
435 # like identifiers and constants.
436 if isinstance(a, AST):
437 return compare(
438 a,
439 b,
440 compare_attributes=compare_attributes,
441 )
442 elif isinstance(a, list):
443 # If a field is repeated, then both objects will represent
444 # the value as a list.
445 if len(a) != len(b):
446 return False
447 for a_item, b_item in zip(a, b):
448 if not _compare(a_item, b_item):
449 return False
450 else:
451 return True
452 else:
453 return type(a) is type(b) and a == b
454
455 def _compare_fields(a, b):
456 if a._fields != b._fields:

Callers 1

_compare_fieldsFunction · 0.85

Calls 1

compareFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…