@@ -233,6 +233,27 @@ QuadPrecision_dealloc(QuadPrecisionObject *self)
233
233
Py_TYPE (self )-> tp_free ((PyObject * )self );
234
234
}
235
235
236
+ PyObject * QuadPrecision_get_pi (PyObject * self , void * closure ) {
237
+ QuadPrecisionObject * new = QuadPrecision_raw_new (BACKEND_SLEEF );
238
+ if (new == NULL ) return NULL ;
239
+ new -> value .sleef_value = SLEEF_M_PIq ;
240
+ return (PyObject * )new ;
241
+ }
242
+
243
+ PyObject * QuadPrecision_get_e (PyObject * self , void * closure ) {
244
+ QuadPrecisionObject * new = QuadPrecision_raw_new (BACKEND_SLEEF );
245
+ if (new == NULL ) return NULL ;
246
+ new -> value .sleef_value = SLEEF_M_Eq ;
247
+ return (PyObject * )new ;
248
+ }
249
+
250
+ // Add this to the existing QuadPrecision_Type definition
251
+ static PyGetSetDef QuadPrecision_getset [] = {
252
+ {"pi" , (getter )QuadPrecision_get_pi , NULL , "Pi constant" , NULL },
253
+ {"e" , (getter )QuadPrecision_get_e , NULL , "Euler's number" , NULL },
254
+ {NULL } /* Sentinel */
255
+ };
256
+
236
257
PyTypeObject QuadPrecision_Type = {
237
258
PyVarObject_HEAD_INIT (NULL , 0 ).tp_name = "numpy_quaddtype.QuadPrecision" ,
238
259
.tp_basicsize = sizeof (QuadPrecisionObject ),
@@ -243,6 +264,7 @@ PyTypeObject QuadPrecision_Type = {
243
264
.tp_str = (reprfunc )QuadPrecision_str_dragon4 ,
244
265
.tp_as_number = & quad_as_scalar ,
245
266
.tp_richcompare = (richcmpfunc )quad_richcompare ,
267
+ .tp_getset = QuadPrecision_getset ,
246
268
};
247
269
248
270
int
0 commit comments