Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(41868)

Delta Between Two Patch Sets: Modules/_uuidmodule.c

Issue 20519: ctypes.create_string_buffer creates reference cycles
Left Patch Set: Created 5 years, 7 months ago
Right Patch Set: Created 3 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/uuid.py ('k') | setup.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #include "Python.h" 1 #include "Python.h"
2 #include <uuid/uuid.h> 2 #include <uuid/uuid.h>
3 3
4 static PyObject * 4 static PyObject *
5 _uuid_generate_random(void) 5 _uuid_generate_random(void)
6 { 6 {
7 uuid_t out; 7 uuid_t out;
8 uuid_generate_random(out); 8 uuid_generate_random(out);
haypo 2015/09/24 13:37:20 Do you think that it's worth to release the GIL he
gustavo 2015/10/26 20:08:21 Generate_random takes about 5 µs each call on my b
9 return PyBytes_FromStringAndSize((const char *) out, sizeof(out)); 9 return PyBytes_FromStringAndSize((const char *) out, sizeof(out));
10 } 10 }
11 11
12 static PyObject * 12 static PyObject *
13 _uuid_generate_time(void) 13 _uuid_generate_time(void)
14 { 14 {
15 uuid_t out; 15 uuid_t out;
16 uuid_generate_time(out); 16 uuid_generate_time(out);
haypo 2015/09/24 13:37:20 Ditto.
gustavo 2015/10/26 20:08:21 generate_time takes 0.1 µs, not worth it.
17 return PyBytes_FromStringAndSize((const char *) out, sizeof(out)); 17 return PyBytes_FromStringAndSize((const char *) out, sizeof(out));
18 } 18 }
19 19
20 20
21 static PyMethodDef uuid_methods[] = { 21 static PyMethodDef uuid_methods[] = {
22 {"generate_random", (PyCFunction)_uuid_generate_random, METH_NOARGS, NULL}, 22 {"generate_random", (PyCFunction)_uuid_generate_random, METH_NOARGS, NULL},
23 {"generate_time", (PyCFunction)_uuid_generate_time, METH_NOARGS, NULL}, 23 {"generate_time", (PyCFunction)_uuid_generate_time, METH_NOARGS, NULL},
24 {NULL, NULL, 0, NULL} /* sentinel */ 24 {NULL, NULL, 0, NULL} /* sentinel */
25 }; 25 };
26 26
27 27
28 static struct PyModuleDef uuidmodule = { 28 static struct PyModuleDef uuidmodule = {
29 PyModuleDef_HEAD_INIT, 29 PyModuleDef_HEAD_INIT,
30 "_uuid", 30 "_uuid",
31 NULL, 31 NULL,
32 -1, 32 -1,
33 uuid_methods, 33 uuid_methods,
34 NULL, 34 NULL,
35 NULL, 35 NULL,
36 NULL, 36 NULL,
37 NULL 37 NULL
38 }; 38 };
39 39
40 PyMODINIT_FUNC 40 PyMODINIT_FUNC
41 PyInit__uuid(void) 41 PyInit__uuid(void)
42 { 42 {
43 assert(sizeof(uuid_t) == 16);
43 return PyModule_Create(&uuidmodule); 44 return PyModule_Create(&uuidmodule);
44 } 45 }
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+