Refactor and clean up str.format() code (and helpers) in advance of optimizations.
diff --git a/Include/floatobject.h b/Include/floatobject.h
index 2021313..650d544 100644
--- a/Include/floatobject.h
+++ b/Include/floatobject.h
@@ -105,6 +105,12 @@
 /* free list api */
 PyAPI_FUNC(void) PyFloat_CompactFreeList(size_t *, size_t *, size_t *);
 
+/* Format the object based on the format_spec, as defined in PEP 3101
+   (Advanced String Formatting). */
+PyAPI_FUNC(PyObject *) _PyFloat_FormatAdvanced(PyObject *obj,
+					       Py_UNICODE *format_spec,
+					       Py_ssize_t format_spec_len);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/Include/formatter_unicode.h b/Include/formatter_unicode.h
deleted file mode 100644
index ccca883..0000000
--- a/Include/formatter_unicode.h
+++ /dev/null
@@ -1,9 +0,0 @@
-PyObject *
-unicode_unicode__format__(PyObject *self, PyObject *args);
-
-PyObject *
-unicode_long__format__(PyObject *self, PyObject *args);
-
-PyObject *
-unicode_float__format__(PyObject *self, PyObject *args);
-
diff --git a/Include/longobject.h b/Include/longobject.h
index 237e2e6..73ca951 100644
--- a/Include/longobject.h
+++ b/Include/longobject.h
@@ -127,6 +127,12 @@
    appending a base prefix of 0[box] if base is 2, 8 or 16. */
 PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *aa, int base);
 
+/* Format the object based on the format_spec, as defined in PEP 3101
+   (Advanced String Formatting). */
+PyAPI_FUNC(PyObject *) _PyLong_FormatAdvanced(PyObject *obj,
+					      Py_UNICODE *format_spec,
+					      Py_ssize_t format_spec_len);
+
 /* These aren't really part of the long object, but they're handy. The
    functions are in Python/mystrtoul.c.
  */
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index 79b9a8c..384cd55 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -571,6 +571,12 @@
 PyAPI_FUNC(PyObject *) PyUnicode_FromFormatV(const char*, va_list);
 PyAPI_FUNC(PyObject *) PyUnicode_FromFormat(const char*, ...);
 
+/* Format the object based on the format_spec, as defined in PEP 3101
+   (Advanced String Formatting). */
+PyAPI_FUNC(PyObject *) _PyUnicode_FormatAdvanced(PyObject *obj,
+                                                 Py_UNICODE *format_spec,
+                                                 Py_ssize_t format_spec_len);
+
 PyAPI_FUNC(void) PyUnicode_InternInPlace(PyObject **);
 PyAPI_FUNC(void) PyUnicode_InternImmortal(PyObject **);
 PyAPI_FUNC(PyObject *) PyUnicode_InternFromString(const char *);