diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2012-10-24 14:33:39 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2012-10-24 14:33:39 +1100 |
commit | ca6c9037faba23798102bd2bc0092f4173c5d9fe (patch) | |
tree | 285b1bcffbe8149cfe06dee76808e78d968d0261 | |
parent | 033834a443b4c4b34445382345ad1abd06245776 (diff) | |
download | mongo-ca6c9037faba23798102bd2bc0092f4173c5d9fe.tar.gz |
Cache cursor key/value formats in Python, to save a native call from every get_key/value.
-rw-r--r-- | lang/python/wiredtiger.i | 8 | ||||
-rw-r--r-- | src/cursor/cur_backup.c | 1 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lang/python/wiredtiger.i b/lang/python/wiredtiger.i index 929d97f9822..d14d6ec507f 100644 --- a/lang/python/wiredtiger.i +++ b/lang/python/wiredtiger.i @@ -55,6 +55,10 @@ from packing import pack, unpack (*$1)->flags |= WT_CURSTD_RAW; PyObject_SetAttrString($result, "is_column", PyBool_FromLong(strcmp((*$1)->key_format, "r") == 0)); + PyObject_SetAttrString($result, "key_format", + PyString_InternFromString((*$1)->key_format)); + PyObject_SetAttrString($result, "value_format", + PyString_InternFromString((*$1)->value_format)); } } @@ -328,8 +332,8 @@ SELFHELPER(struct __wt_cursor, cursor) /* Remove / rename parts of the C API that we don't want in Python. */ %immutable __wt_cursor::session; %immutable __wt_cursor::uri; -%immutable __wt_cursor::key_format; -%immutable __wt_cursor::value_format; +%ignore __wt_cursor::key_format; +%ignore __wt_cursor::value_format; %immutable __wt_session::connection; %ignore __wt_buf; diff --git a/src/cursor/cur_backup.c b/src/cursor/cur_backup.c index d6ff1020390..ecf90f6dc6e 100644 --- a/src/cursor/cur_backup.c +++ b/src/cursor/cur_backup.c @@ -155,6 +155,7 @@ __wt_curbackup_open(WT_SESSION_IMPL *session, cursor->session = &session->iface; cursor->key_format = "S"; /* Return the file names as the key. */ + cursor->value_format = ""; /* No value. */ /* * Start the backup and fill in the cursor's list. Acquire the API |