annotate Objects/stringlib/eq.h @ 87690:66c1c9f32567 default tip

Add use_weakref option to functools.lru_cache The use_weakref option makes lru_cache create weak references to the function arguments when creating the cache key, which prevents them from staying in the memory forever even after all other references to them are gone. This is a proof of concept for http://bugs.python.org/issue19859
author Radomir Dopieralski <devel@sheep.art.pl>
date Tue, 03 Dec 2013 16:02:48 +0100
parents 55c55bfe237b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
44252
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
1 /* Fast unicode equal function optimized for dictobject.c and setobject.c */
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
2
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
3 /* Return 1 if two unicode objects are equal, 0 if not.
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
4 * unicode_eq() is called when the hash of two unicode objects is equal.
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
5 */
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
6 Py_LOCAL_INLINE(int)
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
7 unicode_eq(PyObject *aa, PyObject *bb)
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
8 {
85157
e7f6cef7a4cc Issue #18722: Remove uses of the "register" keyword in C code.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72796
diff changeset
9 PyUnicodeObject *a = (PyUnicodeObject *)aa;
e7f6cef7a4cc Issue #18722: Remove uses of the "register" keyword in C code.
Antoine Pitrou <solipsis@pitrou.net>
parents: 72796
diff changeset
10 PyUnicodeObject *b = (PyUnicodeObject *)bb;
44252
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
11
72475
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 61466
diff changeset
12 if (PyUnicode_READY(a) == -1 || PyUnicode_READY(b) == -1) {
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 61466
diff changeset
13 assert(0 && "unicode_eq ready fail");
61466
cab14be0ada1 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 44252
diff changeset
14 return 0;
72475
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 61466
diff changeset
15 }
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 61466
diff changeset
16
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 61466
diff changeset
17 if (PyUnicode_GET_LENGTH(a) != PyUnicode_GET_LENGTH(b))
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 61466
diff changeset
18 return 0;
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 61466
diff changeset
19 if (PyUnicode_GET_LENGTH(a) == 0)
61466
cab14be0ada1 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 44252
diff changeset
20 return 1;
72475
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 61466
diff changeset
21 if (PyUnicode_KIND(a) != PyUnicode_KIND(b))
61466
cab14be0ada1 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 44252
diff changeset
22 return 0;
72475
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 61466
diff changeset
23 return memcmp(PyUnicode_1BYTE_DATA(a), PyUnicode_1BYTE_DATA(b),
72796
c25262e97304 Change PyUnicode_KIND to 1,2,4. Drop _KIND_SIZE and _CHARACTER_SIZE.
Martin v. Löwis <martin@v.loewis.de>
parents: 72475
diff changeset
24 PyUnicode_GET_LENGTH(a) * PyUnicode_KIND(a)) == 0;
44252
444da08f78a4 Fixed issue #1564: The set implementation should special-case PyUnicode instead of PyString
Christian Heimes <christian@cheimes.de>
parents:
diff changeset
25 }