我通常做的是有两个C函数,它们采用不同的参数。 “python-facing”函数的工作是解析参数,调用适当的C函数,并构建返回值(如果有的话)。 例如,当您想要允许字节和Unicode字符串时,这是很常见的。 这是我的意思的一个例子。// Silly example: get the length of a string, supporting Unicode and byte...