Mercurial > cpython-lru_cache-weakref
comparison Python/sysmodule.c @ 57175:fdd6484f1210
Merge in the new GIL.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Tue, 10 Nov 2009 19:50:40 +0000 |
| parents | 4d38e51e7cdc |
| children | b1a775aa0710 |
comparison
equal
deleted
inserted
replaced
| 57172:6d91aaadddd0 | 57175:fdd6484f1210 |
|---|---|
| 446 \n\ | 446 \n\ |
| 447 Return the profiling function set with sys.setprofile.\n\ | 447 Return the profiling function set with sys.setprofile.\n\ |
| 448 See the profiler chapter in the library manual." | 448 See the profiler chapter in the library manual." |
| 449 ); | 449 ); |
| 450 | 450 |
| 451 /* TODO: deprecate */ | |
| 452 static int _check_interval = 100; | |
| 453 | |
| 451 static PyObject * | 454 static PyObject * |
| 452 sys_setcheckinterval(PyObject *self, PyObject *args) | 455 sys_setcheckinterval(PyObject *self, PyObject *args) |
| 453 { | 456 { |
| 454 if (!PyArg_ParseTuple(args, "i:setcheckinterval", &_Py_CheckInterval)) | 457 if (PyErr_WarnEx(PyExc_DeprecationWarning, |
| 458 "sys.getcheckinterval() and sys.setcheckinterval() " | |
| 459 "are deprecated. Use sys.setswitchinterval() " | |
| 460 "instead.", 1) < 0) | |
| 461 return NULL; | |
| 462 if (!PyArg_ParseTuple(args, "i:setcheckinterval", &_check_interval)) | |
| 455 return NULL; | 463 return NULL; |
| 456 Py_INCREF(Py_None); | 464 Py_INCREF(Py_None); |
| 457 return Py_None; | 465 return Py_None; |
| 458 } | 466 } |
| 459 | 467 |
| 465 ); | 473 ); |
| 466 | 474 |
| 467 static PyObject * | 475 static PyObject * |
| 468 sys_getcheckinterval(PyObject *self, PyObject *args) | 476 sys_getcheckinterval(PyObject *self, PyObject *args) |
| 469 { | 477 { |
| 470 return PyLong_FromLong(_Py_CheckInterval); | 478 if (PyErr_WarnEx(PyExc_DeprecationWarning, |
| 479 "sys.getcheckinterval() and sys.setcheckinterval() " | |
| 480 "are deprecated. Use sys.getswitchinterval() " | |
| 481 "instead.", 1) < 0) | |
| 482 return NULL; | |
| 483 return PyLong_FromLong(_check_interval); | |
| 471 } | 484 } |
| 472 | 485 |
| 473 PyDoc_STRVAR(getcheckinterval_doc, | 486 PyDoc_STRVAR(getcheckinterval_doc, |
| 474 "getcheckinterval() -> current check interval; see setcheckinterval()." | 487 "getcheckinterval() -> current check interval; see setcheckinterval()." |
| 475 ); | 488 ); |
| 489 | |
| 490 #ifdef WITH_THREAD | |
| 491 static PyObject * | |
| 492 sys_setswitchinterval(PyObject *self, PyObject *args) | |
| 493 { | |
| 494 double d; | |
| 495 if (!PyArg_ParseTuple(args, "d:setswitchinterval", &d)) | |
| 496 return NULL; | |
| 497 if (d <= 0.0) { | |
| 498 PyErr_SetString(PyExc_ValueError, | |
| 499 "switch interval must be strictly positive"); | |
| 500 return NULL; | |
| 501 } | |
| 502 _PyEval_SetSwitchInterval((unsigned long) (1e6 * d)); | |
| 503 Py_INCREF(Py_None); | |
| 504 return Py_None; | |
| 505 } | |
| 506 | |
| 507 PyDoc_STRVAR(setswitchinterval_doc, | |
| 508 "setswitchinterval(n)\n\ | |
| 509 \n\ | |
| 510 Set the ideal thread switching delay inside the Python interpreter\n\ | |
| 511 The actual frequency of switching threads can be lower if the\n\ | |
| 512 interpreter executes long sequences of uninterruptible code\n\ | |
| 513 (this is implementation-specific and workload-dependent).\n\ | |
| 514 \n\ | |
| 515 The parameter must represent the desired switching delay in seconds\n\ | |
| 516 A typical value is 0.005 (5 milliseconds)." | |
| 517 ); | |
| 518 | |
| 519 static PyObject * | |
| 520 sys_getswitchinterval(PyObject *self, PyObject *args) | |
| 521 { | |
| 522 return PyFloat_FromDouble(1e-6 * _PyEval_GetSwitchInterval()); | |
| 523 } | |
| 524 | |
| 525 PyDoc_STRVAR(getswitchinterval_doc, | |
| 526 "getswitchinterval() -> current thread switch interval; see setswitchinterval()." | |
| 527 ); | |
| 528 | |
| 529 #endif /* WITH_THREAD */ | |
| 476 | 530 |
| 477 #ifdef WITH_TSC | 531 #ifdef WITH_TSC |
| 478 static PyObject * | 532 static PyObject * |
| 479 sys_settscdump(PyObject *self, PyObject *args) | 533 sys_settscdump(PyObject *self, PyObject *args) |
| 480 { | 534 { |
| 893 setfilesystemencoding_doc}, | 947 setfilesystemencoding_doc}, |
| 894 {"setcheckinterval", sys_setcheckinterval, METH_VARARGS, | 948 {"setcheckinterval", sys_setcheckinterval, METH_VARARGS, |
| 895 setcheckinterval_doc}, | 949 setcheckinterval_doc}, |
| 896 {"getcheckinterval", sys_getcheckinterval, METH_NOARGS, | 950 {"getcheckinterval", sys_getcheckinterval, METH_NOARGS, |
| 897 getcheckinterval_doc}, | 951 getcheckinterval_doc}, |
| 952 #ifdef WITH_THREAD | |
| 953 {"setswitchinterval", sys_setswitchinterval, METH_VARARGS, | |
| 954 setswitchinterval_doc}, | |
| 955 {"getswitchinterval", sys_getswitchinterval, METH_NOARGS, | |
| 956 getswitchinterval_doc}, | |
| 957 #endif | |
| 898 #ifdef HAVE_DLOPEN | 958 #ifdef HAVE_DLOPEN |
| 899 {"setdlopenflags", sys_setdlopenflags, METH_VARARGS, | 959 {"setdlopenflags", sys_setdlopenflags, METH_VARARGS, |
| 900 setdlopenflags_doc}, | 960 setdlopenflags_doc}, |
| 901 #endif | 961 #endif |
| 902 {"setprofile", sys_setprofile, METH_O, setprofile_doc}, | 962 {"setprofile", sys_setprofile, METH_O, setprofile_doc}, |
