Skip to content

Commit

Permalink
Update to xxhash version r37
Browse files Browse the repository at this point in the history
  • Loading branch information
ifduyue committed Oct 23, 2014
1 parent b4ab6fe commit a787475
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 31 deletions.
40 changes: 12 additions & 28 deletions python-xxhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static PyObject *xxh32(PyObject *self, PyObject *args, PyObject *kwargs)
unsigned int ns;
(void)self;

if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|I", keywords, &s, &ns, &seed)) {
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|I:xxh32", keywords, &s, &ns, &seed)) {
return NULL;
}

Expand All @@ -64,7 +64,7 @@ static PyObject *xxh64(PyObject *self, PyObject *args, PyObject *kwargs)
unsigned int ns;
(void)self;

if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|K", keywords, &s, &ns, &seed)) {
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|K:xxh64", keywords, &s, &ns, &seed)) {
return NULL;
}

Expand All @@ -81,15 +81,11 @@ static PyObject *xxh64(PyObject *self, PyObject *args, PyObject *kwargs)
typedef struct {
PyObject_HEAD
/* Type-specific fields go here. */
void *xxhash_state;
XXH32_state_t xxhash_state[1];
} PYXXH32Object;

static void PYXXH32_dealloc(PYXXH32Object *self)
{
if (self->xxhash_state != NULL) {
free(self->xxhash_state);
}

Py_TYPE(self)->tp_free((PyObject *)self);
}

Expand All @@ -105,15 +101,11 @@ static int PYXXH32_init(PYXXH32Object *self, PyObject *args, PyObject *kwargs)
{
unsigned int seed = 0;

if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|I", &keywords[1], &seed)) {
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|I:__init__", &keywords[1], &seed)) {
return -1;
}

self->xxhash_state = XXH32_init(seed);
if (self->xxhash_state == NULL) {
PyErr_NoMemory();
return -1;
}
XXH32_reset(self->xxhash_state, seed);

return 0;
}
Expand All @@ -123,7 +115,7 @@ static PyObject *PYXXH32_update(PYXXH32Object *self, PyObject *args)
const char *s;
unsigned int ns;

if (!PyArg_ParseTuple(args, "s#", &s, &ns)) {
if (!PyArg_ParseTuple(args, "s#:update", &s, &ns)) {
return NULL;
}

Expand All @@ -134,7 +126,7 @@ static PyObject *PYXXH32_update(PYXXH32Object *self, PyObject *args)

static PyObject *PYXXH32_digest(PYXXH32Object *self)
{
unsigned int digest = XXH32_intermediateDigest(self->xxhash_state);
unsigned int digest = XXH32_digest(self->xxhash_state);
return Py_BuildValue("I", digest);
}

Expand Down Expand Up @@ -196,15 +188,11 @@ static PyTypeObject PYXXH32Type = {
typedef struct {
PyObject_HEAD
/* Type-specific fields go here. */
void *xxhash_state;
XXH64_state_t xxhash_state[1];
} PYXXH64Object;

static void PYXXH64_dealloc(PYXXH64Object *self)
{
if (self->xxhash_state != NULL) {
free(self->xxhash_state);
}

((PyObject *)self)->ob_type->tp_free(self);
}

Expand All @@ -220,15 +208,11 @@ static int PYXXH64_init(PYXXH64Object *self, PyObject *args, PyObject *kwargs)
{
unsigned long long seed = 0;

if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|K", &keywords[1], &seed)) {
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|K:__init__", &keywords[1], &seed)) {
return -1;
}

self->xxhash_state = XXH64_init(seed);
if (self->xxhash_state == NULL) {
PyErr_NoMemory();
return -1;
}
XXH64_reset(self->xxhash_state, seed);

return 0;
}
Expand All @@ -238,7 +222,7 @@ static PyObject *PYXXH64_update(PYXXH64Object *self, PyObject *args)
const char *s;
unsigned int ns;

if (!PyArg_ParseTuple(args, "s#", &s, &ns)) {
if (!PyArg_ParseTuple(args, "s#:update", &s, &ns)) {
return NULL;
}

Expand All @@ -249,7 +233,7 @@ static PyObject *PYXXH64_update(PYXXH64Object *self, PyObject *args)

static PyObject *PYXXH64_digest(PYXXH64Object *self)
{
unsigned long long digest = XXH64_intermediateDigest(self->xxhash_state);
unsigned long long digest = XXH64_digest(self->xxhash_state);
return Py_BuildValue("K", digest);
}

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from setuptools import setup, Extension
import os

VERSION = "0.1.2"
XXHASH_VERSION = "r36"
VERSION = "0.1.3"
XXHASH_VERSION = "r37"

if os.name == 'posix':
extra_compile_args = [
Expand Down
2 changes: 1 addition & 1 deletion xxhash
Submodule xxhash updated 5 files
+1 −7 .travis.yml
+18 −22 Makefile
+639 −568 bench.c
+922 −794 xxhash.c
+156 −168 xxhash.h

0 comments on commit a787475

Please sign in to comment.