@@ -312,19 +312,6 @@ bool IsCompliantAttrName(absl::string_view attr_name) {
312312 attr_name);
313313}
314314
315- // classmethod
316- absl::Nullable<PyObject*> PyDataSlice_is_compliant_attr_name (
317- PyObject* cls, PyObject* attr_name) {
318- arolla::python::DCheckPyGIL ();
319- Py_ssize_t size;
320- const char * attr_name_ptr = PyUnicode_AsUTF8AndSize (attr_name, &size);
321- if (attr_name_ptr == nullptr ) {
322- return nullptr ;
323- }
324- auto attr_name_view = absl::string_view (attr_name_ptr, size);
325- return PyBool_FromLong (IsCompliantAttrName (attr_name_view));
326- }
327-
328315absl::Nullable<PyObject*> PyDataSlice_getattro (PyObject* self,
329316 PyObject* attr_name) {
330317 arolla::python::DCheckPyGIL ();
@@ -963,28 +950,6 @@ absl::Nullable<PyObject*> PyDataSlice_debug_repr(PyObject* self) {
963950 debug_repr.c_str (), static_cast <Py_ssize_t>(debug_repr.size ()));
964951}
965952
966- // classmethod
967- absl::Nullable<PyObject*>
968- PyDataSlice_internal_register_reserved_class_method_name (
969- PyTypeObject* cls, PyObject* method_name) {
970- arolla::python::DCheckPyGIL ();
971- if (!PyUnicode_Check (method_name)) {
972- PyErr_SetString (PyExc_TypeError, " method name must be a string" );
973- return nullptr ;
974- }
975- Py_ssize_t size;
976- const char * method_name_ptr = PyUnicode_AsUTF8AndSize (method_name, &size);
977- if (method_name_ptr == nullptr ) {
978- return nullptr ;
979- }
980- auto method_name_view = absl::string_view (method_name_ptr, size);
981- if (size == 0 || method_name_view[0 ] != ' _' ) {
982- PyDataSlice_GetReservedAttrsWithoutLeadingUnderscore ().insert (
983- method_name_view);
984- }
985- Py_RETURN_NONE;
986- }
987-
988953PyMethodDef kPyDataSlice_methods [] = {
989954 {" get_bag" , PyDataSlice_get_bag, METH_NOARGS,
990955 " get_bag()\n "
@@ -1220,29 +1185,12 @@ schema. In case of ANY (or primitives), an empty list is returned.
12201185 " Returns a format representation with a special support for non empty "
12211186 " specification.\n\n DataSlice will be replaced with base64 encoded "
12221187 " DataSlice.\n Must be used with kd.fstr or kde.fstr." },
1223- {" internal_register_reserved_class_method_name" ,
1224- (PyCFunction)PyDataSlice_internal_register_reserved_class_method_name,
1225- METH_CLASS | METH_O,
1226- " internal_register_reserved_class_method_name(method_name, /)\n "
1227- " --\n\n "
1228- " Registers a name to be reserved as a method of the DataSlice class.\n "
1229- " \n "
1230- " You must call this when adding new methods to the class in Python.\n "
1231- " \n "
1232- " Args:\n "
1233- " method_name: (str)\n " },
12341188 {" _repr_with_params" , (PyCFunction)PyDataSlice_repr_with_params,
12351189 METH_FASTCALL | METH_KEYWORDS,
12361190 " _repr_with_params("
12371191 " *, depth=1, unbounded_type_max_len=-1, format_html=False)\n "
12381192 " --\n\n "
12391193 " Used to generate str representation for interactive repr in Colab." },
1240- {" internal_is_compliant_attr_name" ,
1241- (PyCFunction)PyDataSlice_is_compliant_attr_name, METH_CLASS | METH_O,
1242- " internal_is_compliant_attr_name(attr_name, /)\n "
1243- " --\n\n "
1244- " Returns true iff `attr_name` can be accessed through "
1245- " `getattr(slice, attr_name)`." },
12461194 {" _debug_repr" , (PyCFunction)PyDataSlice_debug_repr, METH_NOARGS,
12471195 " _debug_repr()\n "
12481196 " --\n\n "
@@ -1349,4 +1297,37 @@ PyTypeObject* PyDataSlice_Type() {
13491297 return type;
13501298}
13511299
1300+ // data_slice_py_ext module methods
1301+ absl::Nullable<PyObject*> PyDataSliceModule_is_compliant_attr_name (
1302+ PyObject* /* module*/ , PyObject* attr_name) {
1303+ arolla::python::DCheckPyGIL ();
1304+ Py_ssize_t size;
1305+ const char * attr_name_ptr = PyUnicode_AsUTF8AndSize (attr_name, &size);
1306+ if (attr_name_ptr == nullptr ) {
1307+ return nullptr ;
1308+ }
1309+ auto attr_name_view = absl::string_view (attr_name_ptr, size);
1310+ return PyBool_FromLong (IsCompliantAttrName (attr_name_view));
1311+ }
1312+
1313+ absl::Nullable<PyObject*> PyDataSliceModule_register_reserved_class_method_name (
1314+ PyObject* /* module*/ , PyObject* method_name) {
1315+ arolla::python::DCheckPyGIL ();
1316+ if (!PyUnicode_Check (method_name)) {
1317+ PyErr_SetString (PyExc_TypeError, " method name must be a string" );
1318+ return nullptr ;
1319+ }
1320+ Py_ssize_t size;
1321+ const char * method_name_ptr = PyUnicode_AsUTF8AndSize (method_name, &size);
1322+ if (method_name_ptr == nullptr ) {
1323+ return nullptr ;
1324+ }
1325+ auto method_name_view = absl::string_view (method_name_ptr, size);
1326+ if (size == 0 || method_name_view[0 ] != ' _' ) {
1327+ PyDataSlice_GetReservedAttrsWithoutLeadingUnderscore ().insert (
1328+ method_name_view);
1329+ }
1330+ Py_RETURN_NONE;
1331+ }
1332+
13521333} // namespace koladata::python
0 commit comments