@@ -502,64 +502,31 @@ BufferWithSegmentsCollection_item(ZstdBufferWithSegmentsCollection *self,
502502 return NULL ;
503503}
504504
505- static PySequenceMethods BufferWithSegmentsCollection_sq = {
506- (lenfunc )BufferWithSegmentsCollection_length , /* sq_length */
507- 0 , /* sq_concat */
508- 0 , /* sq_repeat */
509- (ssizeargfunc )BufferWithSegmentsCollection_item , /* sq_item */
510- 0 , /* sq_ass_item */
511- 0 , /* sq_contains */
512- 0 , /* sq_inplace_concat */
513- 0 /* sq_inplace_repeat */
514- };
515-
516505static PyMethodDef BufferWithSegmentsCollection_methods [] = {
517506 {"size" , (PyCFunction )BufferWithSegmentsCollection_size , METH_NOARGS ,
518507 PyDoc_STR ("total size in bytes of all segments" )},
519508 {NULL , NULL }};
520509
521- PyTypeObject ZstdBufferWithSegmentsCollectionType = {
522- PyVarObject_HEAD_INIT (NULL ,
523- 0 ) "zstd.BufferWithSegmentsCollection" , /* tp_name */
524- sizeof (ZstdBufferWithSegmentsCollection ), /* tp_basicsize */
525- 0 , /* tp_itemsize */
526- (destructor )BufferWithSegmentsCollection_dealloc , /* tp_dealloc */
527- 0 , /* tp_print */
528- 0 , /* tp_getattr */
529- 0 , /* tp_setattr */
530- 0 , /* tp_compare */
531- 0 , /* tp_repr */
532- 0 , /* tp_as_number */
533- & BufferWithSegmentsCollection_sq , /* tp_as_sequence */
534- 0 , /* tp_as_mapping */
535- 0 , /* tp_hash */
536- 0 , /* tp_call */
537- 0 , /* tp_str */
538- 0 , /* tp_getattro */
539- 0 , /* tp_setattro */
540- 0 , /* tp_as_buffer */
541- Py_TPFLAGS_DEFAULT , /* tp_flags */
542- 0 , /* tp_doc */
543- 0 , /* tp_traverse */
544- 0 , /* tp_clear */
545- 0 , /* tp_richcompare */
546- 0 , /* tp_weaklistoffset */
547- /* TODO implement iterator for performance. */
548- 0 , /* tp_iter */
549- 0 , /* tp_iternext */
550- BufferWithSegmentsCollection_methods , /* tp_methods */
551- 0 , /* tp_members */
552- 0 , /* tp_getset */
553- 0 , /* tp_base */
554- 0 , /* tp_dict */
555- 0 , /* tp_descr_get */
556- 0 , /* tp_descr_set */
557- 0 , /* tp_dictoffset */
558- (initproc )BufferWithSegmentsCollection_init , /* tp_init */
559- 0 , /* tp_alloc */
560- PyType_GenericNew , /* tp_new */
510+ PyType_Slot ZstdBufferWithSegmentsCollectionSlots [] = {
511+ {Py_tp_dealloc , BufferWithSegmentsCollection_dealloc },
512+ {Py_sq_length , BufferWithSegmentsCollection_length },
513+ {Py_sq_item , BufferWithSegmentsCollection_item },
514+ {Py_tp_methods , BufferWithSegmentsCollection_methods },
515+ {Py_tp_init , BufferWithSegmentsCollection_init },
516+ {Py_tp_new , PyType_GenericNew },
517+ {0 , NULL },
561518};
562519
520+ PyType_Spec ZstdBufferWithSegmentsCollectionSpec = {
521+ "zstd.BufferWithSegmentsCollection" ,
522+ sizeof (ZstdBufferWithSegmentsCollection ),
523+ 0 ,
524+ Py_TPFLAGS_DEFAULT ,
525+ ZstdBufferWithSegmentsCollectionSlots ,
526+ };
527+
528+ PyTypeObject * ZstdBufferWithSegmentsCollectionType ;
529+
563530void bufferutil_module_init (PyObject * mod ) {
564531 ZstdBufferWithSegmentsType =
565532 (PyTypeObject * )PyType_FromSpec (& ZstdBufferWithSegmentsSpec );
@@ -599,12 +566,13 @@ void bufferutil_module_init(PyObject *mod) {
599566 Py_INCREF (ZstdBufferSegmentType );
600567 PyModule_AddObject (mod , "BufferSegment" , (PyObject * )ZstdBufferSegmentType );
601568
602- Py_SET_TYPE (& ZstdBufferWithSegmentsCollectionType , & PyType_Type );
603- if (PyType_Ready (& ZstdBufferWithSegmentsCollectionType ) < 0 ) {
569+ ZstdBufferWithSegmentsCollectionType =
570+ (PyTypeObject * )PyType_FromSpec (& ZstdBufferWithSegmentsCollectionSpec );
571+ if (PyType_Ready (ZstdBufferWithSegmentsCollectionType ) < 0 ) {
604572 return ;
605573 }
606574
607- Py_INCREF (& ZstdBufferWithSegmentsCollectionType );
575+ Py_INCREF (ZstdBufferWithSegmentsCollectionType );
608576 PyModule_AddObject (mod , "BufferWithSegmentsCollection" ,
609- (PyObject * )& ZstdBufferWithSegmentsCollectionType );
577+ (PyObject * )ZstdBufferWithSegmentsCollectionType );
610578}
0 commit comments