Skip to main content

This is a simple package about Data Structure packed by C/C++ language.

Project description

总览

安装

pip install AdroitFisherman

API内部对象

1、常量定义

typedef PyObject* ElemType;

2、SeqListObject结构

typedef struct
{
    PyObject_HEAD
        ElemType* elem;
    int length;
    int size;
}SeqList;

3、SeqListObject插槽相关函数定义

(1)tp_new

static PyObject* SeqList_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
    SeqList* list;
    list = (SeqList*)type->tp_alloc(type, 0);
    if (list == NULL)
    {
        PyErr_SetString(PyExc_Exception, "list object created failure!");
        return NULL;
    }
    else
    {
        list->elem = NULL;
        list->length = 0;
        list->size = 0;
        return (PyObject*)list;
    }
}

(2)tp_dealloc

static void SeqList_destroy(SeqList* self)
{
    Py_DECREF(self->elem);
    printf("DEBUG:[any_thread]-- This object has been released!");
    Py_TYPE(self)->tp_free(self);
}

(3)tp_new

static PyObject* SeqList_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
    SeqList* list;
    list = (SeqList*)type->tp_alloc(type, 0);
    if (list == NULL)
    {
        PyErr_SetString(PyExc_Exception, "list object created failure!");
        return NULL;
    }
    else
    {
        list->elem = NULL;
        list->length = 0;
        list->size = 0;
        return (PyObject*)list;
    }
}

(4)tp_init

static int SeqList_init(SeqList* self, PyObject* args, PyObject* kwds)
{
    Py_INCREF(self);
    return 0;
}

4、SeqListObject内部成员定义

static PyMemberDef SeqList_members[] = {
    {"elem",T_OBJECT,offsetof(SeqList,elem),0,""},
    {"length",T_INT,offsetof(SeqList,length),0,""},
    {"size",T_INT,offsetof(SeqList,size),0,""},
    {NULL}
};

5、SeqListObject内部方法定义

static PyMethodDef SeqList_methods[] = {
    {"init_list",InitList,METH_VARARGS,""},
    {"destroy_list",DestroyList,METH_VARARGS,""},
    {"clear_list",ClearList,METH_VARARGS,""},
    {"list_empty",ListEmpty,METH_VARARGS,""},
    {"list_length",ListLength,METH_VARARGS,""},
    {"get_elem",GetElem,METH_VARARGS,""},
    {"list_insert",ListInsert,METH_VARARGS,""},
    {"list_delete",ListDelete,METH_VARARGS,""},
    {"traverse_list",TraverseList,METH_VARARGS,""},
    {NULL}
};

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

AdroitFisherman-0.0.24.tar.gz (5.3 kB view details)

Uploaded Source

File details

Details for the file AdroitFisherman-0.0.24.tar.gz.

File metadata

  • Download URL: AdroitFisherman-0.0.24.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.11

File hashes

Hashes for AdroitFisherman-0.0.24.tar.gz
Algorithm Hash digest
SHA256 9c6544644c08fc35ad73ae15e1f4b0ee2deea56e5204395d9dafe2616056c766
MD5 b8a5a6f1a454a8e710971ffc49fbdc46
BLAKE2b-256 cc7ab09c24878728370397a5f330c7d0108f1221ff8277f16d72afe898804ebc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page