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
4b74fba6
Kaydet (Commit)
4b74fba6
authored
May 03, 2014
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 21101: Internal API for dict getitem and setitem where the hash value is known.
üst
1b5eebcf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
dictobject.h
Include/dictobject.h
+4
-0
dictobject.c
Objects/dictobject.c
+56
-0
No files found.
Include/dictobject.h
Dosyayı görüntüle @
4b74fba6
...
...
@@ -50,6 +50,8 @@ PyAPI_DATA(PyTypeObject) PyDictValues_Type;
PyAPI_FUNC
(
PyObject
*
)
PyDict_New
(
void
);
PyAPI_FUNC
(
PyObject
*
)
PyDict_GetItem
(
PyObject
*
mp
,
PyObject
*
key
);
PyAPI_FUNC
(
PyObject
*
)
_PyDict_GetItem_KnownHash
(
PyObject
*
mp
,
PyObject
*
key
,
Py_hash_t
hash
);
PyAPI_FUNC
(
PyObject
*
)
PyDict_GetItemWithError
(
PyObject
*
mp
,
PyObject
*
key
);
PyAPI_FUNC
(
PyObject
*
)
_PyDict_GetItemIdWithError
(
PyObject
*
dp
,
struct
_Py_Identifier
*
key
);
...
...
@@ -58,6 +60,8 @@ PyAPI_FUNC(PyObject *) PyDict_SetDefault(
PyObject
*
mp
,
PyObject
*
key
,
PyObject
*
defaultobj
);
#endif
PyAPI_FUNC
(
int
)
PyDict_SetItem
(
PyObject
*
mp
,
PyObject
*
key
,
PyObject
*
item
);
PyAPI_FUNC
(
int
)
_PyDict_SetItem_KnownHash
(
PyObject
*
mp
,
PyObject
*
key
,
PyObject
*
item
,
Py_hash_t
hash
);
PyAPI_FUNC
(
int
)
PyDict_DelItem
(
PyObject
*
mp
,
PyObject
*
key
);
PyAPI_FUNC
(
void
)
PyDict_Clear
(
PyObject
*
mp
);
PyAPI_FUNC
(
int
)
PyDict_Next
(
...
...
Objects/dictobject.c
Dosyayı görüntüle @
4b74fba6
...
...
@@ -1101,6 +1101,44 @@ PyDict_GetItem(PyObject *op, PyObject *key)
return
*
value_addr
;
}
PyObject
*
_PyDict_GetItem_KnownHash
(
PyObject
*
op
,
PyObject
*
key
,
Py_hash_t
hash
)
{
PyDictObject
*
mp
=
(
PyDictObject
*
)
op
;
PyDictKeyEntry
*
ep
;
PyThreadState
*
tstate
;
PyObject
**
value_addr
;
if
(
!
PyDict_Check
(
op
))
return
NULL
;
/* We can arrive here with a NULL tstate during initialization: try
running "python -Wi" for an example related to string interning.
Let's just hope that no exception occurs then... This must be
_PyThreadState_Current and not PyThreadState_GET() because in debug
mode, the latter complains if tstate is NULL. */
tstate
=
(
PyThreadState
*
)
_Py_atomic_load_relaxed
(
&
_PyThreadState_Current
);
if
(
tstate
!=
NULL
&&
tstate
->
curexc_type
!=
NULL
)
{
/* preserve the existing exception */
PyObject
*
err_type
,
*
err_value
,
*
err_tb
;
PyErr_Fetch
(
&
err_type
,
&
err_value
,
&
err_tb
);
ep
=
(
mp
->
ma_keys
->
dk_lookup
)(
mp
,
key
,
hash
,
&
value_addr
);
/* ignore errors */
PyErr_Restore
(
err_type
,
err_value
,
err_tb
);
if
(
ep
==
NULL
)
return
NULL
;
}
else
{
ep
=
(
mp
->
ma_keys
->
dk_lookup
)(
mp
,
key
,
hash
,
&
value_addr
);
if
(
ep
==
NULL
)
{
PyErr_Clear
();
return
NULL
;
}
}
return
*
value_addr
;
}
/* Variant of PyDict_GetItem() that doesn't suppress exceptions.
This returns NULL *with* an exception set if an exception occurred.
It returns NULL *without* an exception set if the key wasn't present.
...
...
@@ -1207,6 +1245,24 @@ PyDict_SetItem(PyObject *op, PyObject *key, PyObject *value)
return
insertdict
(
mp
,
key
,
hash
,
value
);
}
int
_PyDict_SetItem_KnownHash
(
PyObject
*
op
,
PyObject
*
key
,
PyObject
*
value
,
Py_hash_t
hash
)
{
PyDictObject
*
mp
;
if
(
!
PyDict_Check
(
op
))
{
PyErr_BadInternalCall
();
return
-
1
;
}
assert
(
key
);
assert
(
value
);
mp
=
(
PyDictObject
*
)
op
;
/* insertdict() handles any resizing that might be necessary */
return
insertdict
(
mp
,
key
,
hash
,
value
);
}
int
PyDict_DelItem
(
PyObject
*
op
,
PyObject
*
key
)
{
...
...
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