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
d8b9e1fc
Kaydet (Commit)
d8b9e1fc
authored
Şub 20, 2019
tarafından
Stefan Behnel
Kaydeden (comit)
Raymond Hettinger
Şub 20, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-36012: Avoid linear slot search for non-dunder methods (GH-11907)
üst
b5409dac
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
13 deletions
+45
-13
3.8.rst
Doc/whatsnew/3.8.rst
+5
-0
2019-02-19-10-47-51.bpo-36012.xq7C9E.rst
...ore and Builtins/2019-02-19-10-47-51.bpo-36012.xq7C9E.rst
+2
-0
typeobject.c
Objects/typeobject.c
+38
-13
No files found.
Doc/whatsnew/3.8.rst
Dosyayı görüntüle @
d8b9e1fc
...
...
@@ -375,6 +375,11 @@ Optimizations
This makes the created list 12% smaller on average. (Contributed by
Raymond Hettinger and Pablo Galindo in :issue:`33234`.)
* Doubled the speed of class variable writes. When a non-dunder attribute
was updated, there was an unnecessary call to update slots.
(Contributed by Stefan Behnel, Pablo Galindo Salgado, Raymond Hettinger,
Neil Schemenauer, and Serhiy Storchaka in :issue:`36012`.)
Build and C API Changes
=======================
...
...
Misc/NEWS.d/next/Core and Builtins/2019-02-19-10-47-51.bpo-36012.xq7C9E.rst
0 → 100644
Dosyayı görüntüle @
d8b9e1fc
Doubled the speed of class variable writes. When a non-dunder attribute was
updated, there was an unnecessary call to update slots.
Objects/typeobject.c
Dosyayı görüntüle @
d8b9e1fc
...
...
@@ -3164,6 +3164,24 @@ _PyType_LookupId(PyTypeObject *type, struct _Py_Identifier *name)
return
_PyType_Lookup
(
type
,
oname
);
}
/* Check if the "readied" PyUnicode name
is a double-underscore special name. */
static
int
is_dunder_name
(
PyObject
*
name
)
{
Py_ssize_t
length
=
PyUnicode_GET_LENGTH
(
name
);
int
kind
=
PyUnicode_KIND
(
name
);
/* Special names contain at least "__x__" and are always ASCII. */
if
(
length
>
4
&&
kind
==
PyUnicode_1BYTE_KIND
)
{
Py_UCS1
*
characters
=
PyUnicode_1BYTE_DATA
(
name
);
return
(
((
characters
[
length
-
2
]
==
'_'
)
&&
(
characters
[
length
-
1
]
==
'_'
))
&&
((
characters
[
0
]
==
'_'
)
&&
(
characters
[
1
]
==
'_'
))
);
}
return
0
;
}
/* This is similar to PyObject_GenericGetAttr(),
but uses _PyType_Lookup() instead of just looking in type->tp_dict. */
static
PyObject
*
...
...
@@ -3275,12 +3293,14 @@ type_setattro(PyTypeObject *type, PyObject *name, PyObject *value)
if
(
name
==
NULL
)
return
-
1
;
}
PyUnicode_InternInPlace
(
&
name
);
if
(
!
PyUnicode_CHECK_INTERNED
(
name
))
{
PyErr_SetString
(
PyExc_MemoryError
,
"Out of memory interning an attribute name"
);
Py_DECREF
(
name
);
return
-
1
;
PyUnicode_InternInPlace
(
&
name
);
if
(
!
PyUnicode_CHECK_INTERNED
(
name
))
{
PyErr_SetString
(
PyExc_MemoryError
,
"Out of memory interning an attribute name"
);
Py_DECREF
(
name
);
return
-
1
;
}
}
}
else
{
...
...
@@ -3289,7 +3309,16 @@ type_setattro(PyTypeObject *type, PyObject *name, PyObject *value)
}
res
=
_PyObject_GenericSetAttrWithDict
((
PyObject
*
)
type
,
name
,
value
,
NULL
);
if
(
res
==
0
)
{
res
=
update_slot
(
type
,
name
);
/* Clear the VALID_VERSION flag of 'type' and all its
subclasses. This could possibly be unified with the
update_subclasses() recursion in update_slot(), but carefully:
they each have their own conditions on which to stop
recursing into subclasses. */
PyType_Modified
(
type
);
if
(
is_dunder_name
(
name
))
{
res
=
update_slot
(
type
,
name
);
}
assert
(
_PyType_CheckConsistency
(
type
));
}
Py_DECREF
(
name
);
...
...
@@ -7236,13 +7265,6 @@ update_slot(PyTypeObject *type, PyObject *name)
assert
(
PyUnicode_CheckExact
(
name
));
assert
(
PyUnicode_CHECK_INTERNED
(
name
));
/* Clear the VALID_VERSION flag of 'type' and all its
subclasses. This could possibly be unified with the
update_subclasses() recursion below, but carefully:
they each have their own conditions on which to stop
recursing into subclasses. */
PyType_Modified
(
type
);
init_slotdefs
();
pp
=
ptrs
;
for
(
p
=
slotdefs
;
p
->
name
;
p
++
)
{
...
...
@@ -7281,6 +7303,9 @@ update_all_slots(PyTypeObject* type)
{
slotdef
*
p
;
/* Clear the VALID_VERSION flag of 'type' and all its subclasses. */
PyType_Modified
(
type
);
init_slotdefs
();
for
(
p
=
slotdefs
;
p
->
name
;
p
++
)
{
/* update_slot returns int but can't actually fail */
...
...
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