Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
6075a822
Kaydet (Commit)
6075a822
authored
Şub 06, 2008
tarafından
Christian Heimes
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Limit free list of method and builtin function objects to 256 entries each.
üst
45eda646
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
8 deletions
+38
-8
NEWS
Misc/NEWS
+3
-0
classobject.c
Objects/classobject.c
+18
-5
methodobject.c
Objects/methodobject.c
+17
-3
No files found.
Misc/NEWS
Dosyayı görüntüle @
6075a822
...
...
@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1?
Core and builtins
-----------------
- Limit free list of method and builtin function objects to 256 entries
each.
- Patch #1953: Added ``sys._compact_freelists()`` and the C API functions
``PyInt_CompactFreeList`` and ``PyFloat_CompactFreeList``
to compact the internal free lists of pre-allocted ints and floats.
...
...
Objects/classobject.c
Dosyayı görüntüle @
6075a822
...
...
@@ -4,10 +4,16 @@
#include "Python.h"
#include "structmember.h"
/* Free list for method objects to safe malloc/free overhead
* The im_self element is used to chain the elements.
*/
static
PyMethodObject
*
free_list
;
static
int
numfree
=
0
;
#define MAXFREELIST 256
#define TP_DESCR_GET(t) \
(PyType_HasFeature(t, Py_TPFLAGS_HAVE_CLASS) ? (t)->tp_descr_get : NULL)
/* Forward */
static
PyObject
*
class_lookup
(
PyClassObject
*
,
PyObject
*
,
PyClassObject
**
);
...
...
@@ -2193,8 +2199,6 @@ PyTypeObject PyInstance_Type = {
In case (b), im_self is NULL
*/
static
PyMethodObject
*
free_list
;
PyObject
*
PyMethod_New
(
PyObject
*
func
,
PyObject
*
self
,
PyObject
*
klass
)
{
...
...
@@ -2207,6 +2211,7 @@ PyMethod_New(PyObject *func, PyObject *self, PyObject *klass)
if
(
im
!=
NULL
)
{
free_list
=
(
PyMethodObject
*
)(
im
->
im_self
);
PyObject_INIT
(
im
,
&
PyMethod_Type
);
numfree
--
;
}
else
{
im
=
PyObject_GC_New
(
PyMethodObject
,
&
PyMethod_Type
);
...
...
@@ -2332,8 +2337,14 @@ instancemethod_dealloc(register PyMethodObject *im)
Py_DECREF
(
im
->
im_func
);
Py_XDECREF
(
im
->
im_self
);
Py_XDECREF
(
im
->
im_class
);
im
->
im_self
=
(
PyObject
*
)
free_list
;
free_list
=
im
;
if
(
numfree
<
MAXFREELIST
)
{
im
->
im_self
=
(
PyObject
*
)
free_list
;
free_list
=
im
;
numfree
++
;
}
else
{
PyObject_GC_Del
(
im
);
}
}
static
int
...
...
@@ -2620,5 +2631,7 @@ PyMethod_Fini(void)
PyMethodObject
*
im
=
free_list
;
free_list
=
(
PyMethodObject
*
)(
im
->
im_self
);
PyObject_GC_Del
(
im
);
numfree
--
;
}
assert
(
numfree
==
0
);
}
Objects/methodobject.c
Dosyayı görüntüle @
6075a822
...
...
@@ -4,7 +4,12 @@
#include "Python.h"
#include "structmember.h"
/* Free list for method objects to safe malloc/free overhead
* The m_self element is used to chain the objects.
*/
static
PyCFunctionObject
*
free_list
=
NULL
;
static
int
numfree
=
0
;
#define MAXFREELIST 256
PyObject
*
PyCFunction_NewEx
(
PyMethodDef
*
ml
,
PyObject
*
self
,
PyObject
*
module
)
...
...
@@ -14,6 +19,7 @@ PyCFunction_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module)
if
(
op
!=
NULL
)
{
free_list
=
(
PyCFunctionObject
*
)(
op
->
m_self
);
PyObject_INIT
(
op
,
&
PyCFunction_Type
);
numfree
--
;
}
else
{
op
=
PyObject_GC_New
(
PyCFunctionObject
,
&
PyCFunction_Type
);
...
...
@@ -125,8 +131,14 @@ meth_dealloc(PyCFunctionObject *m)
_PyObject_GC_UNTRACK
(
m
);
Py_XDECREF
(
m
->
m_self
);
Py_XDECREF
(
m
->
m_module
);
m
->
m_self
=
(
PyObject
*
)
free_list
;
free_list
=
m
;
if
(
numfree
<
MAXFREELIST
)
{
m
->
m_self
=
(
PyObject
*
)
free_list
;
free_list
=
m
;
numfree
++
;
}
else
{
PyObject_GC_Del
(
m
);
}
}
static
PyObject
*
...
...
@@ -346,14 +358,16 @@ PyCFunction_Fini(void)
PyCFunctionObject
*
v
=
free_list
;
free_list
=
(
PyCFunctionObject
*
)(
v
->
m_self
);
PyObject_GC_Del
(
v
);
numfree
--
;
}
assert
(
numfree
==
0
);
}
/* PyCFunction_New() is now just a macro that calls PyCFunction_NewEx(),
but it's part of the API so we need to keep a function around that
existing C extensions can call.
*/
#undef PyCFunction_New
PyAPI_FUNC
(
PyObject
*
)
PyCFunction_New
(
PyMethodDef
*
,
PyObject
*
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment