comparison Python/sysmodule.c @ 45145:3d7b84daa34a

Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552-60567 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60553 | neal.norwitz | 2008-02-03 17:53:09 +0100 (Sun, 03 Feb 2008) | 1 line Ignore leaky warnings from test_asynchat ........ r60555 | christian.heimes | 2008-02-03 20:51:13 +0100 (Sun, 03 Feb 2008) | 1 line Another int -> pid_t case ........ r60560 | amaury.forgeotdarc | 2008-02-03 23:51:43 +0100 (Sun, 03 Feb 2008) | 6 lines Ensure that PySet_Add() operates on a newly created frozenset, like PyTuple_SetItem does. Add PyFrozenSet_Check(), which was not needed before; The list of Py*Set_Check* macros seems to be complete now. Add missing NEWS entries about all this. ........ r60563 | amaury.forgeotdarc | 2008-02-04 00:14:32 +0100 (Mon, 04 Feb 2008) | 2 lines Nasty typo in setobject.h ........ r60564 | amaury.forgeotdarc | 2008-02-04 00:15:32 +0100 (Mon, 04 Feb 2008) | 3 lines Correct test_mailbox on win32: since the test sets a custom 'colon' attribute to the main mailbox, copy it to secondary mailbox instances. ........ r60565 | amaury.forgeotdarc | 2008-02-04 00:57:24 +0100 (Mon, 04 Feb 2008) | 2 lines Let test_socketserver pass on win32, which does not have AF_UNIX sockets. ........ r60566 | jeffrey.yasskin | 2008-02-04 02:04:35 +0100 (Mon, 04 Feb 2008) | 2 lines Make int() and long() fall back to __trunc__(). See issue 2002. ........ r60567 | christian.heimes | 2008-02-04 19:00:12 +0100 (Mon, 04 Feb 2008) | 3 lines Patch #1953 I implemented the function sys._compact_freelists() and C API functions PyInt_/PyFloat_CompactFreeList() to compact the pre-allocated blocks of ints and floats. They allow the user to reduce the memory usage of a Python process that deals with lots of numbers. The patch also renames sys._cleartypecache to sys._clear_type_cache ........
author Christian Heimes <christian@cheimes.de>
date Mon, 04 Feb 2008 18:48:49 +0000
parents f380d991390e
children 22a74eaf6b22
comparison
equal deleted inserted replaced
45136:eb97e8302fa3 45145:3d7b84daa34a
728 8. generator calls\n\ 728 8. generator calls\n\
729 9. All other calls\n\ 729 9. All other calls\n\
730 10. Number of stack pops performed by call_function()" 730 10. Number of stack pops performed by call_function()"
731 ); 731 );
732 732
733 static PyObject *
734 sys_cleartypecache(PyObject* self, PyObject* args)
735 {
736 PyType_ClearCache();
737 Py_RETURN_NONE;
738 }
739
740 PyDoc_STRVAR(cleartypecache_doc,
741 "_cleartypecache() -> None\n\
742 Clear the internal type lookup cache.");
743
744 #ifdef __cplusplus 733 #ifdef __cplusplus
745 extern "C" { 734 extern "C" {
746 #endif 735 #endif
747 736
748 #ifdef Py_TRACE_REFS 737 #ifdef Py_TRACE_REFS
756 #endif 745 #endif
757 746
758 #ifdef __cplusplus 747 #ifdef __cplusplus
759 } 748 }
760 #endif 749 #endif
750
751 static PyObject *
752 sys_clear_type_cache(PyObject* self, PyObject* args)
753 {
754 PyType_ClearCache();
755 Py_RETURN_NONE;
756 }
757
758 PyDoc_STRVAR(sys_clear_type_cache__doc__,
759 "_clear_type_cache() -> None\n\
760 Clear the internal type lookup cache.");
761
762
763 static PyObject *
764 sys_compact_freelists(PyObject* self, PyObject* args)
765 {
766 size_t fsum, fbc, fbf;
767
768 PyFloat_CompactFreeList(&fbc, &fbf, &fsum);
769
770 return Py_BuildValue("((kkk))", fsum, fbc, fbf);
771
772 }
773
774 PyDoc_STRVAR(sys_compact_freelists__doc__,
775 "_compact_freelists() -> ((remaing_objects, total_blocks, freed_blocks),)\n\
776 Compact the free lists of floats.");
761 777
762 static PyMethodDef sys_methods[] = { 778 static PyMethodDef sys_methods[] = {
763 /* Might as well keep this in alphabetic order */ 779 /* Might as well keep this in alphabetic order */
764 {"callstats", (PyCFunction)PyEval_GetCallStats, METH_NOARGS, 780 {"callstats", (PyCFunction)PyEval_GetCallStats, METH_NOARGS,
765 callstats_doc}, 781 callstats_doc},
766 {"_cleartypecache", sys_cleartypecache, METH_NOARGS, 782 {"_clear_type_cache", sys_clear_type_cache, METH_NOARGS,
767 cleartypecache_doc}, 783 sys_clear_type_cache__doc__},
784 {"_compact_freelists", sys_compact_freelists, METH_NOARGS,
785 sys_compact_freelists__doc__},
768 {"_current_frames", sys_current_frames, METH_NOARGS, 786 {"_current_frames", sys_current_frames, METH_NOARGS,
769 current_frames_doc}, 787 current_frames_doc},
770 {"displayhook", sys_displayhook, METH_O, displayhook_doc}, 788 {"displayhook", sys_displayhook, METH_O, displayhook_doc},
771 {"exc_info", sys_exc_info, METH_NOARGS, exc_info_doc}, 789 {"exc_info", sys_exc_info, METH_NOARGS, exc_info_doc},
772 {"excepthook", sys_excepthook, METH_VARARGS, excepthook_doc}, 790 {"excepthook", sys_excepthook, METH_VARARGS, excepthook_doc},