conversion.pxd 1.7 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # From https://docs.python.org/3/c-api/conversion.html
  2. from .object cimport PyObject
  3. cdef extern from "Python.h":
  4. ctypedef struct va_list
  5. int PyOS_snprintf(char *str, size_t size, const char *format, ...)
  6. # Output not more than size bytes to str according to the format
  7. # string format and the extra arguments. See the Unix man page snprintf(2).
  8. int PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va)
  9. # Output not more than size bytes to str according to the format
  10. # string format and the variable argument list va. Unix man page vsnprintf(2).
  11. double PyOS_string_to_double(const char *s, char **endptr, PyObject *overflow_exception) except? -1.0
  12. # Convert a string s to a double, raising a Python exception on failure. The set of
  13. # accepted strings corresponds to the set of strings accepted by Python’s float()
  14. # constructor, except that s must not have leading or trailing whitespace.
  15. # The conversion is independent of the current locale.
  16. enum:
  17. Py_DTSF_SIGN
  18. Py_DTSF_ADD_DOT_0
  19. Py_DTSF_ALT
  20. char* PyOS_double_to_string(double val, char format_code, int precision, int flags, int *ptype) except NULL
  21. # Convert a double val to a string using supplied format_code, precision, and flags.
  22. int PyOS_stricmp(const char *s1, const char *s2)
  23. # Case insensitive comparison of strings. The function works almost identically
  24. # to strcmp() except that it ignores the case.
  25. int PyOS_strnicmp(const char *s1, const char *s2, Py_ssize_t size)
  26. # Case insensitive comparison of strings. The function works almost identically
  27. # to strncmp() except that it ignores the case.