Path 1: 397 calls (0.86)

Const (397)

'default' (397)

SphinxDocstring (155) GoogleDocstring (131) NumpyDocstring (111)

1def docstringify(
2    docstring: nodes.Const | None, default_type: str = "default"
3) -> Docstring:
4    best_match = (0, DOCSTRING_TYPES.get(default_type, Docstring)(docstring))
5    for docstring_type in (
6        SphinxDocstring,
7        EpytextDocstring,
8        GoogleDocstring,
9        NumpyDocstring,
10    ):
11        instance = docstring_type(docstring)
12        matching_sections = instance.matching_sections()
13        if matching_sections > best_match[0]:
14            best_match = (matching_sections, instance)
15
16    return best_match[1]
            

Path 2: 65 calls (0.14)

Const (38) None (27)

'default' (65)

Docstring (65)

1def docstringify(
2    docstring: nodes.Const | None, default_type: str = "default"
3) -> Docstring:
4    best_match = (0, DOCSTRING_TYPES.get(default_type, Docstring)(docstring))
5    for docstring_type in (
6        SphinxDocstring,
7        EpytextDocstring,
8        GoogleDocstring,
9        NumpyDocstring,
10    ):
11        instance = docstring_type(docstring)
12        matching_sections = instance.matching_sections()
13        if matching_sections > best_match[0]:
14            best_match = (matching_sections, instance)
15
16    return best_match[1]