<commit_before>
cimport cython

cdef class MyType:
    def __cinit__(self):
        print "CINIT"
    def __init__(self):
        print "INIT"

cdef class MySubType(MyType):
    def __cinit__(self):
        print "CINIT(SUB)"
    def __init__(self):
        print "INIT"

class MyClass(object):
    def __cinit__(self):
        print "CINIT"
    def __init__(self):
        print "INIT"

class MyTypeSubClass(MyType):
    def __cinit__(self):
        # not called: Python class!
        print "CINIT(PYSUB)"
    def __init__(self):
        print "INIT"

# only this can be safely optimised:

@cython.test_assert_path_exists('//PythonCapiCallNode')
@cython.test_fail_if_path_exists('//SimpleCallNode/AttributeNode')
def make_new():
    """
    >>> isinstance(make_new(), MyType)
    CINIT
    True
    """
    m = MyType.__new__(MyType)
    return m

@cython.test_assert_path_exists('//PythonCapiCallNode')
@cython.test_fail_if_path_exists('//SimpleCallNode/AttributeNode')
def make_new_typed_target():
    """
    >>> isinstance(make_new_typed_target(), MyType)
    CINIT
    True
    """<commit_msg>comment<commit_after>
cimport cython

cdef class MyType:
    def __cinit__(self):
        print "CINIT"
    def __init__(self):
        print "INIT"

cdef class MySubType(MyType):
    def __cinit__(self):
        print "CINIT(SUB)"
    def __init__(self):
        print "INIT"

class MyClass(object):
    def __cinit__(self):
        print "CINIT"
    def __init__(self):
        print "INIT"

class MyTypeSubClass(MyType):
    def __cinit__(self):
        # not called: Python class!
        print "CINIT(PYSUB)"
    def __init__(self):
        print "INIT"

# only these can be safely optimised:

@cython.test_assert_path_exists('//PythonCapiCallNode')
@cython.test_fail_if_path_exists('//SimpleCallNode/AttributeNode')
def make_new():
    """
    >>> isinstance(make_new(), MyType)
    CINIT
    True
    """
    m = MyType.__new__(MyType)
    return m

@cython.test_assert_path_exists('//PythonCapiCallNode')
@cython.test_fail_if_path_exists('//SimpleCallNode/AttributeNode')
def make_new_typed_target():
    """
    >>> isinstance(make_new_typed_target(), MyType)
    CINIT
    True
    """
{'fraction_non_alphanumeric': 0.12209567198177676, 'fraction_numerical': 0.0, 'mean_word_length': 3.2640776699029126, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6678433', 'n_tokens_mistral': 751, 'n_tokens_neox': 748, 'n_words': 150}