extending and embedding python py_replace(pyobject *selfpyobject *argspyobject *kwargsstatic char *argnames[{" ","och","nch",null}char * ,*sdupchar ochnchint nreppyobject *resultif (!pyarg_parsetupleandkeywords(args,kwargs"scc:replace"argnames& &och&nch)return nullsdup (char *malloc(strlen( )+ )strcpy(sdup, )nrep replace(sdup,och,nch)result py_buildvalue("(is)",nrep,sdup)free(sdup)return resultstatic char py_distance_doc["computes the distance between two points"static pyobject py_distance(pyobject *selfpyobject *argspyerr_setstring(pyexc_notimplementederror,"distance(not implemented ")return nullstatic pymethoddef _examplemethods[{"gcd"py_gcdmeth_varargspy_gcd_doc}{"replace"py_replacemeth_varargs meth_keywordspy_replace_doc}{"distance",py_distance,meth_varargspy_distance_doc}{nullnull null}#if py_major_version /python module initialization *void init_example(voidpyobject *modmod py_initmodule("_example"_examplemethods)pymodule_addintmacro(mod,magic)#else /python module initialization *static struct pymoduledef _examplemodule pymoduledef_head_init"_example"/name of module *null/module documentationmay be null *- _examplemethods }pymodinit_func pyinit_ _example(voidpyobject *modmod pymodule_create(&_examplemodule)pymodule_addintmacro(modmagic)return mod#endif extension modules always need to include "python hfor each function to be accesseda wrapper function is written these wrapper functions accept either two arguments (self and argsboth of type pyobject *or three arguments (selfargsf lib fl ff