<commit_before># TODO: Figure out how many of the pass-by-value copies the compiler can eliminate.


#################### string.from_py ####################

cdef extern from *:
    cdef cppclass string "std::string":
        string(char* c_str, size_t size)

@cname("{{cname}}")
cdef string {{cname}}(object o) except *:
    return string(<char*>o, len(o))


#################### string.to_py ####################

#cimport cython
#from libcpp.string cimport string
cdef extern from *:
    cdef cppclass string "const std::string":
        char* c_str()
        size_t size()

@cname("{{cname}}")
cdef object {{cname}}(string& s):
    return s.c_str()[:s.size()]


#################### vector.from_py ####################

cdef extern from *:
    ctypedef struct X "{{T0}}":
        pass
    cdef X X_from_py "{{T0_from_py}}" (object) except *

cdef extern from *:
    cdef cppclass vector "std::vector" [T]:
        void push_back(T&)

@cname("{{cname}}")<commit_msg>Don't need terminating null for Python conversion.<commit_after># TODO: Figure out how many of the pass-by-value copies the compiler can eliminate.


#################### string.from_py ####################

cdef extern from *:
    cdef cppclass string "std::string":
        string(char* c_str, size_t size)

@cname("{{cname}}")
cdef string {{cname}}(object o) except *:
    return string(<char*>o, len(o))


#################### string.to_py ####################

#cimport cython
#from libcpp.string cimport string
cdef extern from *:
    cdef cppclass string "const std::string":
        char* data()
        size_t size()

@cname("{{cname}}")
cdef object {{cname}}(string& s):
    return s.data()[:s.size()]


#################### vector.from_py ####################

cdef extern from *:
    ctypedef struct X "{{T0}}":
        pass
    cdef X X_from_py "{{T0_from_py}}" (object) except *

cdef extern from *:
    cdef cppclass vector "std::vector" [T]:
        void push_back(T&)

@cname("{{cname}}")
{'fraction_non_alphanumeric': 0.25113924050632913, 'fraction_numerical': 0.0020253164556962027, 'mean_word_length': 4.145833333333333, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 5, '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': '6933031', 'n_tokens_mistral': 660, 'n_tokens_neox': 649, 'n_words': 179}