summaryrefslogtreecommitdiff
path: root/msgpack
diff options
context:
space:
mode:
authorinada-n <songofacandy@gmail.com>2009-12-17 15:19:18 +0900
committerinada-n <songofacandy@gmail.com>2009-12-17 15:19:18 +0900
commit658c90f132d9582ec1e8ec68a30f9e67b8d7a572 (patch)
tree76d207312aed6d8043973af4cbcb090ccbf986b2 /msgpack
parent77e3e59620d65589451c833fa01e9c9e5f39624d (diff)
downloadmsgpack-python-658c90f132d9582ec1e8ec68a30f9e67b8d7a572.tar.gz
Make tuple default.
Diffstat (limited to 'msgpack')
-rw-r--r--msgpack/_msgpack.pyx12
-rw-r--r--msgpack/unpack.h12
2 files changed, 11 insertions, 13 deletions
diff --git a/msgpack/_msgpack.pyx b/msgpack/_msgpack.pyx
index b20ad7b..eb83c85 100644
--- a/msgpack/_msgpack.pyx
+++ b/msgpack/_msgpack.pyx
@@ -152,7 +152,7 @@ packs = packb
cdef extern from "unpack.h":
ctypedef struct msgpack_user:
- int use_tuple
+ int use_list
ctypedef struct template_context:
msgpack_user user
@@ -174,7 +174,7 @@ def unpackb(object packed_bytes):
cdef size_t off = 0
cdef int ret
template_init(&ctx)
- ctx.user.use_tuple = 0
+ ctx.user.use_list = 0
ret = template_execute(&ctx, p, len(packed_bytes), &off)
if ret == 1:
return template_data(&ctx)
@@ -230,7 +230,7 @@ cdef class Unpacker(object):
cdef object file_like
cdef int read_size
cdef object waiting_bytes
- cdef int use_tuple
+ cdef int use_list
def __cinit__(self):
self.buf = NULL
@@ -239,10 +239,10 @@ cdef class Unpacker(object):
if self.buf:
free(self.buf);
- def __init__(self, file_like=None, int read_size=0, use_tuple=0):
+ def __init__(self, file_like=None, int read_size=0, use_list=0):
if read_size == 0:
read_size = 1024*1024
- self.use_tuple = use_tuple
+ self.use_list = use_list
self.file_like = file_like
self.read_size = read_size
self.waiting_bytes = []
@@ -251,7 +251,7 @@ cdef class Unpacker(object):
self.buf_head = 0
self.buf_tail = 0
template_init(&self.ctx)
- self.ctx.user.use_tuple = use_tuple
+ self.ctx.user.use_list = use_list
def feed(self, next_bytes):
if not isinstance(next_bytes, str):
diff --git a/msgpack/unpack.h b/msgpack/unpack.h
index 0bf2568..61a3786 100644
--- a/msgpack/unpack.h
+++ b/msgpack/unpack.h
@@ -20,7 +20,7 @@
#include "unpack_define.h"
typedef struct unpack_user {
- int use_tuple;
+ int use_list;
} unpack_user;
@@ -136,7 +136,7 @@ static inline int template_callback_false(unpack_user* u, msgpack_unpack_object*
static inline int template_callback_array(unpack_user* u, unsigned int n, msgpack_unpack_object* o)
{
- PyObject *p = u->use_tuple ? PyTuple_New(n) : PyList_New(n);
+ PyObject *p = u->use_list ? PyList_New(n) : PyTuple_New(n);
if (!p)
return -1;
@@ -146,12 +146,10 @@ static inline int template_callback_array(unpack_user* u, unsigned int n, msgpac
static inline int template_callback_array_item(unpack_user* u, unsigned int current, msgpack_unpack_object* c, msgpack_unpack_object o)
{
- if (u->use_tuple) {
- PyTuple_SET_ITEM(*c, current, o);
- }
- else {
+ if (u->use_list)
PyList_SET_ITEM(*c, current, o);
- }
+ else
+ PyTuple_SET_ITEM(*c, current, o);
return 0;
}