• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PySequence_Fast_GET_SIZE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PySequence_Fast_GET_SIZE函数的典型用法代码示例。如果您正苦于以下问题:C++ PySequence_Fast_GET_SIZE函数的具体用法?C++ PySequence_Fast_GET_SIZE怎么用?C++ PySequence_Fast_GET_SIZE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PySequence_Fast_GET_SIZE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: _NonPyObjectUniqueSorterIncer

 _NonPyObjectUniqueSorterIncer(PyObject * fast_seq) 
 {           
     if (fast_seq == Py_None)
         return;
 
     vals.reserve(PySequence_Fast_GET_SIZE(fast_seq));            
     for (size_t i = 0; i < static_cast<size_t>(PySequence_Fast_GET_SIZE(fast_seq)); ++i) {    
         PyObject * const val = PySequence_Fast_GET_ITEM(fast_seq, i);    
         DBG_ASSERT(PyTuple_Check(val));
         DBG_ASSERT(PyTuple_Size(val) == 2);
         PyObject * const key = PyTuple_GET_ITEM(val, 0);
         BANYAN_PYOBJECT_INCREF(key);
         vals.push_back(std::make_pair(
             std::make_pair(                    
                 _KeyFactory<Key_Type>::convert(key), 
                 key),
             PyTuple_GET_ITEM(val, 1)));
     }            
         
     _FirstLT<_FirstLT<std::less<Key_Type> > > lt;            
     std::sort(vals.begin(), vals.end(), lt);
     vals.erase(unique(vals.begin(), vals.end(), not2(lt)), vals.end());
     
     for (size_t i = 0; i < vals.size(); ++i)
         BANYAN_PYOBJECT_INCREF(vals[i].second);            
 }
开发者ID:danielballan,项目名称:banyan,代码行数:26,代码来源:_tree_imp_non_pyobject_key_value_type_dict_base.hpp


示例2: references

/*
 This symbol filters its children through a python function...  where anything is possible.

 functions are generated differently than other symbols:
 - each arg is generated into the output, but the start/end of each arg is recorded for later
 - after references (@symbols) are resolved, then all the functions can be called
 - function output replaces the args in the output (may be bigger or smaller than arg length)
 - function args may contain other function calls, so when function return replaces it's args,
   need to check if this falls within the range of another function arg, and if so repair the range
 */
static int
_generate_function(PyObject *s, void *g)
{
    PyObject *res, *l;
    int status, i, func_cookie, has_ref, defer_depth;
    int *args, nargs;

    // generate arg values
    l = PySequence_Fast(SYMOBJ(s)->data.func.args, "Error enumerating function args");
    if (!l)
        return -1;
    nargs = PySequence_Fast_GET_SIZE(l);
    args = (int *)malloc(sizeof(int) * (nargs + 1));
    if (!args) {
        Py_DECREF(l);
        PyErr_NoMemory();
        return -1;
    }
    args[0] = gen_state_tell(g);
    func_cookie = gen_state_enter_function(g);
    defer_depth = ((gen_state_t *)g)->nfuncs;
    for (i = 0; i < PySequence_Fast_GET_SIZE(l); i++) {
        status = _generate(SYMOBJ(PySequence_Fast_GET_ITEM(l, i)), g);
        if (status) {
            Py_DECREF(l);
            free(args);
            return -1;
        }
        args[i+1] = gen_state_tell(g); // mark end of this arg
    }
    Py_DECREF(l);
    has_ref = gen_state_leave_function(g, func_cookie);
    if (has_ref) {
        // function call must be deferred until after references are generated
        return gen_state_defer_function(g, s, nargs, args, defer_depth);
    } else {
        // call function now
        const char *strres;
        res = call_func_now(s, g, nargs, args);
        gen_state_backtrack(g, args[0]);
        free(args);
        if (!res)
            return -1;
        strres = PyBytes_AsString(res);
        if (!strres) {
            Py_DECREF(res);
            return -1;
        }
        status = gen_state_write((gen_state_t *)g, strres, PyBytes_GET_SIZE(res));
        Py_DECREF(res);
        return status;
    }
}
开发者ID:blackberry,项目名称:ALF,代码行数:63,代码来源:symbol.c


示例3: pycairo_set_dash

static PyObject *
pycairo_set_dash (PycairoContext *o, PyObject *args) {
  double *dashes, offset = 0;
  int num_dashes, i;
  PyObject *py_dashes;

  if (!PyArg_ParseTuple (args, "O|d:Context.set_dash", &py_dashes, &offset))
    return NULL;

  py_dashes = PySequence_Fast (py_dashes,
			       "first argument must be a sequence");
  if (py_dashes == NULL)
    return NULL;

  num_dashes = PySequence_Fast_GET_SIZE(py_dashes);
  dashes = PyMem_Malloc (num_dashes * sizeof(double));
  if (dashes == NULL) {
    Py_DECREF(py_dashes);
    return PyErr_NoMemory();
  }

  for (i = 0; i < num_dashes; i++) {
    dashes[i] = PyFloat_AsDouble(PySequence_Fast_GET_ITEM(py_dashes, i));
    if (PyErr_Occurred()) {
      PyMem_Free (dashes);
      Py_DECREF(py_dashes);
      return NULL;
    }
  }
  cairo_set_dash (o->ctx, dashes, num_dashes, offset);
  PyMem_Free (dashes);
  Py_DECREF(py_dashes);
  RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
  Py_RETURN_NONE;
}
开发者ID:Distrotech,项目名称:pycairo,代码行数:35,代码来源:context.c


示例4: PositionWeightMatrix_scoreAll

static PyObject* PositionWeightMatrix_scoreAll( PositionWeightMatrix* self, PyObject* args )
{
	PyObject* seq = parseTupleToFastSequence( args );
	if( !seq ) return NULL;
	
	double** matrix = self -> matrix;
	int n = self -> n;
	int m = self -> m;
	int len = PySequence_Fast_GET_SIZE( seq );
	//check that length is correct
	if( n > len )
	{
		//TODO raise error
		return NULL;
	}
	
	PyObject** elems = PySequence_Fast_ITEMS( seq );
	
	//create new python list and fill it with the scores at each position
	int end = len - n + 1;
	PyObject* list = PyList_New( end );
	int i;
	for( i = 0 ; i < end ; ++i )
	{
		PyList_SetItem( list, i, PyFloat_FromDouble( scoreFromIndex( matrix, n, m, elems, i ) ) );
	}
	return list;
	
}
开发者ID:tbepler,项目名称:MESS,代码行数:29,代码来源:PositionWeightMatrix.c


示例5: PySequence_Fast

/*
 * Callback function which is exposed as a part of the additional methods which allow
 * a Python plugin to issue a Register Event to register additional events it wants
 * to receive.
 */
static PyObject *PyBareosRegisterEvents(PyObject *self, PyObject *args)
{
   int len, event;
   bpContext *ctx;
   PyObject *pyCtx, *pyEvents, *pySeq, *pyEvent;

   if (!PyArg_ParseTuple(args, "OO:BareosRegisterEvents", &pyCtx, &pyEvents)) {
      return NULL;
   }

   pySeq = PySequence_Fast(pyEvents, "Expected a sequence of events");
   if (!pySeq) {
      return NULL;
   }

   len = PySequence_Fast_GET_SIZE(pySeq);

   ctx = PyGetbpContext(pyCtx);
   for (int i = 0; i < len; i++) {
      pyEvent = PySequence_Fast_GET_ITEM(pySeq, i);
      event = PyInt_AsLong(pyEvent);

      if (event >= bDirEventJobStart && event <= bDirEventGetScratch) {
         Dmsg(ctx, dbglvl, "PyBareosRegisterEvents: registering event %d\n", event);
         bfuncs->registerBareosEvents(ctx, 1, event);
      }
   }

   Py_DECREF(pySeq);

   Py_INCREF(Py_None);
   return Py_None;
}
开发者ID:bitroniq,项目名称:bareos,代码行数:38,代码来源:python-dir.c


示例6: pathlist_new

static PyObject* pathlist_new(PyTypeObject* pytype, PyObject* args,
			      PyObject* kwds) {
  PyObject* py_arg = 0;
  if (PyArg_ParseTuple(args, "|O", &py_arg) <= 0)
    return 0;
  boost::shared_ptr<PathList> p(new PathList());
  if (py_arg != 0) {
    PyObject* seq = PySequence_Fast(py_arg, "Argument must be a sequence of Path objects.");
    if (seq == 0)
      return 0;
    int size = PySequence_Fast_GET_SIZE(seq);
    for (int i = 0; i < size; ++i) {
      PyObject* py_path = PySequence_Fast_GET_ITEM(seq, i);
      if (!is_PathObject(py_path)) {
	PyErr_SetString(PyExc_TypeError, "Argument must be a sequence of Path objects.");
	Py_DECREF(seq);
	return 0;
      }
      p->push_back(((PathObject*)py_path)->m_x);
    }
  }
  
  PathListObject* so;
  so = (PathListObject*)pytype->tp_alloc(pytype, 0);
  so->m_x = p;
  return (PyObject*)so;
}
开发者ID:elaboris,项目名称:gamera,代码行数:27,代码来源:pathlistobject.cpp


示例7: pygdk_atom_vector_from_sequence

GdkAtom*
pygdk_atom_vector_from_sequence(PyObject *py_targets, gint *n_targets)
{
    gint i;
    GdkAtom *targets;

    if (!(py_targets = PySequence_Fast(py_targets,
                                       "targets must be a sequence")))
        return NULL;

    *n_targets = PySequence_Fast_GET_SIZE(py_targets);
    targets = g_new(GdkAtom, *n_targets);
    for (i = 0; i < *n_targets; i++) {
        PyObject *trgt = PySequence_Fast_GET_ITEM(py_targets, i);
        targets[i] = pygdk_atom_from_pyobject(trgt);
        if (PyErr_Occurred()) {
            PyErr_Clear();
            PyErr_SetString(PyExc_TypeError,
                            "each 'targets' item must be a GdkAtom or string");
            g_free(targets);
            Py_DECREF(py_targets);
            return NULL;
        }
    }
    Py_DECREF(py_targets);
    return targets;
}
开发者ID:Chiheb-Nexus,项目名称:pygtk,代码行数:27,代码来源:gtkobject-support.c


示例8: pygtk_target_list_from_sequence

GtkTargetList *
pygtk_target_list_from_sequence(PyObject *py_targets)
{
    gint n_targets, i;
    GtkTargetEntry *targets;
    GtkTargetList *target_list;

    if (!(py_targets = PySequence_Fast(py_targets,
                                       "target list must be a sequence")))
	return NULL;
    n_targets = PySequence_Fast_GET_SIZE(py_targets);
    targets = g_new(GtkTargetEntry, n_targets);
    for (i = 0; i < n_targets; i++) {
        PyObject *item = PySequence_Fast_GET_ITEM(py_targets, i);
        if (!PyArg_ParseTuple(item, "sii", &targets[i].target,
                              &targets[i].flags, &targets[i].info)) {
            PyErr_Clear();
            PyErr_SetString(PyExc_TypeError,
                            "target list items should be of form (string,int,int)");
            g_free(targets);
	    Py_DECREF(py_targets);
            return NULL;
        }
    }
    target_list = gtk_target_list_new(targets, n_targets);
    g_free(targets);
    Py_DECREF(py_targets);
    return target_list;
}
开发者ID:Chiheb-Nexus,项目名称:pygtk,代码行数:29,代码来源:gtkobject-support.c


示例9: py_array_from_obj

int py_array_from_obj(PyObject *obj, float *arr) {

   PyObject *seqdata = NULL;
   PyObject *elem;
   int i;

  if (!(seqdata = PySequence_Fast(obj, "Coordinate argument must be a sequence")))
    goto failure;

  if (PySequence_Fast_GET_SIZE(seqdata) != 3) {
    PyErr_SetString(PyExc_ValueError, "Coordinate must have length 3");
    goto failure;
  }

  for (i = 0; i < 3; i++) {
    elem = PySequence_Fast_GET_ITEM(seqdata, i);

    arr[i] = PyFloat_AsDouble(elem);
    if (PyErr_Occurred()) {
      PyErr_SetString(PyExc_ValueError, "Problem unpacking coordinate");
      goto failure;
    }
  }
  return 1;  // successful return

failure:
  Py_XDECREF(seqdata);
  return 0;
}
开发者ID:Eigenstate,项目名称:vmd-python,代码行数:29,代码来源:py_commands.C


示例10: pycairo_set_dash

static PyObject *
pycairo_set_dash (PycairoContext *o, PyObject *args)
{
    double *dashes, offset = 0;
    int ndash, i;
    PyObject *py_dashes;

    if (!PyArg_ParseTuple (args, "O|d:Context.set_dash", &py_dashes, &offset))
	return NULL;

    py_dashes = PySequence_Fast (py_dashes,
				 "first argument must be a sequence");
    if (!py_dashes)
	return NULL;

    ndash = PySequence_Fast_GET_SIZE(py_dashes);
    dashes = malloc (ndash * sizeof(double));
    for (i = 0; i < ndash; i++) {
	PyObject *item = PySequence_Fast_GET_ITEM(py_dashes, i);

	dashes[i] = PyFloat_AsDouble(item);
	if (PyErr_Occurred()) {
	    free (dashes);
	    Py_DECREF(py_dashes);
	    return NULL;
	}
    }
    Py_DECREF(py_dashes);

    cairo_set_dash (o->ctx, dashes, ndash, offset);
    free (dashes);
    if (Pycairo_Check_Status (cairo_status (o->ctx)))
	return NULL;
    Py_RETURN_NONE;
}
开发者ID:anarcher,项目名称:enso-launcher-continued,代码行数:35,代码来源:pycairo-context.c


示例11: ImageViewport_setCaptureSize

// set capture size
int ImageViewport_setCaptureSize(PyImage *self, PyObject *value, void *closure)
{
	// check validity of parameter
	if (value == NULL ||
	    !(PyTuple_Check(value) || PyList_Check(value)) ||
	    PySequence_Fast_GET_SIZE(value) != 2 ||
	    !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0)) ||
	    !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1)))
	{
		PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 ints");
		return -1;
	}
	// set capture size
	short size[2] = {
	    short(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
	    short(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 1)))
	};
	try
	{
		// can throw in case of resize and buffer exports
		getImageViewport(self)->setCaptureSize(size);
	}
	catch (Exception & exp)
	{
		exp.report();
		return -1;
	}
	// success
	return 0;
}
开发者ID:DarkDefender,项目名称:blender-npr-tess2,代码行数:31,代码来源:ImageViewport.cpp


示例12: mathutils_array_parse_alloc_v

/* parse an array of vectors */
int mathutils_array_parse_alloc_v(float **array, int array_dim, PyObject *value, const char *error_prefix)
{
	PyObject *value_fast = NULL;
	int i, size;

	/* non list/tuple cases */
	if (!(value_fast = PySequence_Fast(value, error_prefix))) {
		/* PySequence_Fast sets the error */
		return -1;
	}

	size = PySequence_Fast_GET_SIZE(value_fast);

	if (size != 0) {
		float *fp;

		fp = *array = PyMem_Malloc(size * array_dim * sizeof(float));

		for (i = 0; i < size; i++, fp += array_dim) {
			PyObject *item = PySequence_Fast_GET_ITEM(value, i);

			if (mathutils_array_parse(fp, array_dim, array_dim, item, error_prefix) == -1) {
				PyMem_Free(*array);
				*array = NULL;
				size = -1;
				break;
			}
		}
	}

	Py_DECREF(value_fast);
	return size;
}
开发者ID:Eibriel,项目名称:kiriblender,代码行数:34,代码来源:mathutils.c


示例13: sequenceToIntArray

int* sequenceToIntArray(PyObject* obj, bool zeroTerminated)
{
    AutoDecRef seq(PySequence_Fast(obj, "Sequence of ints expected"));
    if (seq.isNull())
        return 0;

    Py_ssize_t size = PySequence_Fast_GET_SIZE(seq.object());
    int* array = new int[size + (zeroTerminated ? 1 : 0)];

    for (int i = 0; i < size; i++) {
        PyObject* item = PySequence_Fast_GET_ITEM(seq.object(), i);
        if (!PyInt_Check(item)) {
            PyErr_SetString(PyExc_TypeError, "Sequence of ints expected");
            delete[] array;
            return 0;
        } else {
            array[i] = PyInt_AsLong(item);
        }
    }

    if (zeroTerminated)
        array[size] = 0;

    return array;
}
开发者ID:lauromoura,项目名称:Shiboken,代码行数:25,代码来源:helper.cpp


示例14: IntVector_from_python

inline IntVector* IntVector_from_python(PyObject* py) {
  PyObject* seq = PySequence_Fast(py, "Argument must be a sequence of ints.");
  if (seq == NULL)
    return 0;
  int size = PySequence_Fast_GET_SIZE(seq);
  IntVector* cpp = new IntVector(size);
  try {
    for (int i = 0; i < size; ++i) {
      PyObject* number = PySequence_Fast_GET_ITEM(seq, i);
      if (!PyInt_Check(number)) {
        PyErr_SetString(PyExc_TypeError,
                        "Argument must be a sequence of ints.");
        delete cpp;
        Py_DECREF(seq);
        return 0;
      }
      (*cpp)[i] = (int)PyInt_AsLong(number);
    }
  } catch (std::exception e) {
    delete cpp;
    Py_DECREF(seq);
    PyErr_SetString(PyExc_RuntimeError, e.what());
    return 0;
  }
  Py_DECREF(seq);
  return cpp;
}
开发者ID:elaboris,项目名称:gamera,代码行数:27,代码来源:gameramodule.hpp


示例15: convert_seq

static PyObject*
convert_seq(PyObject *ob, convert_func convert_string)
{
    PyObject *seq = PySequence_Fast(ob, "ob is not a sequence");
    if (seq == NULL) {
        return NULL;
    }

    Py_ssize_t i = 0;
    Py_ssize_t seq_len = PySequence_Fast_GET_SIZE(seq);
    PyObject **items = PySequence_Fast_ITEMS(seq);

    for (i=0; i < seq_len; ++i) {
        PyObject *old_item = items[i];
        PyObject *new_item = convert_nested(old_item, convert_string);
        if (new_item == NULL) {
            Py_DECREF(seq);
            return NULL;
        }
        items[i] = new_item;
        Py_DECREF(old_item);
    }

    return seq;
}
开发者ID:axiros,项目名称:nested_encode,代码行数:25,代码来源:_convert_nested.c


示例16: ComplexVector_from_python

inline ComplexVector* ComplexVector_from_python(PyObject* py) {
  PyObject* seq = PySequence_Fast(py, "Argument must be a sequence of complex numbers.");
  if (seq == NULL)
    return 0;
  int size = PySequence_Fast_GET_SIZE(seq);
  ComplexVector* cpp = new ComplexVector(size);
  try {
    for (int i = 0; i < size; ++i) {
      PyObject* value = PySequence_Fast_GET_ITEM(seq, i);
      if (!PyComplex_Check(value)) {
        delete cpp;
        Py_DECREF(seq);
        PyErr_SetString(PyExc_TypeError, "Argument must be a sequence of complex numbers.");
        return 0;
      }
      Py_complex temp = PyComplex_AsCComplex(value);
      (*cpp)[i] = ComplexPixel(temp.real, temp.imag);
    }
  } catch (std::exception e) {
    delete cpp;
    Py_DECREF(seq);
    PyErr_SetString(PyExc_RuntimeError, e.what());
    return 0;
  }
  Py_DECREF(seq);
  return cpp;
}
开发者ID:elaboris,项目名称:gamera,代码行数:27,代码来源:gameramodule.hpp


示例17: process_domains

static void process_domains(PyObject *domains, char ***rdomains, int *ndomains)
{
    Py_ssize_t i, n;
    PyObject *item, *data_fast;
    char **c_domains;
    char *arg_str, *tmp_str;

    c_domains = NULL;

    *rdomains = NULL;
    *ndomains = 0;

    if ((data_fast = PySequence_Fast(domains, "argument 1 must be an iterable")) == NULL) {
        goto cleanup;
    }

    n = PySequence_Fast_GET_SIZE(data_fast);
    if (n > INT_MAX) {
        PyErr_SetString(PyExc_ValueError, "argument 1 is too long");
        goto cleanup;
    }

    if (n == 0) {
        return;
    }

    c_domains = (char **)PyMem_Malloc(sizeof(char *) * n+1);
    if (!c_domains) {
        PyErr_NoMemory();
        goto cleanup;
    }
    memset(c_domains, 0, n+1);
    i = 0;
    while (i < n) {
        item = PySequence_Fast_GET_ITEM(data_fast, i);
        if (!item || !PyArg_Parse(item, "s;args contains a non-string value", &arg_str)) {
            Py_XDECREF(item);
            goto cleanup;
        }
        Py_DECREF(item);
        tmp_str = (char *) PyMem_Malloc(strlen(arg_str) + 1);
        if (!tmp_str) {
            PyErr_NoMemory();
            goto cleanup;
        }
        strcpy(tmp_str, arg_str);
        c_domains[i] = tmp_str;
        i++;
    }
    c_domains[n] = NULL;

    *rdomains = c_domains;
    *ndomains = n;
    return;

cleanup:
    *rdomains = NULL;
    *ndomains = -1;
    free_domains(c_domains);
}
开发者ID:IsCoolEntertainment,项目名称:debpkg_python-pycares,代码行数:60,代码来源:cares.c


示例18: PyBlitzArray_getitem

static PyObject* PyBlitzArray_getitem(PyBlitzArrayObject* self,
    PyObject* item) {

  if (PyBob_NumberCheck(item)) {

    if (self->ndim != 1) {
      PyErr_Format(PyExc_TypeError, "expected tuple for accessing %" PY_FORMAT_SIZE_T "dD array", self->ndim);
      return 0;
    }

    // if you get to this point, the user has passed single number
    Py_ssize_t k = PyNumber_AsSsize_t(item, PyExc_IndexError);
    return PyBlitzArray_GetItem(self, &k);

  }

  if (PySequence_Check(item)) {

    if (self->ndim != PySequence_Fast_GET_SIZE(item)) {
      PyErr_Format(PyExc_TypeError, "expected tuple of size %" PY_FORMAT_SIZE_T "d for accessing %" PY_FORMAT_SIZE_T "dD array", self->ndim, self->ndim);
      return 0;
    }

    // if you get to this point, then the input tuple has the same size
    PyBlitzArrayObject shape;
    PyBlitzArrayObject* shape_p = &shape;
    if (!PyBlitzArray_IndexConverter(item, &shape_p)) return 0;
    return PyBlitzArray_GetItem(self, shape.shape);

  }

  PyErr_Format(PyExc_TypeError, "%s(@%" PY_FORMAT_SIZE_T "d,'%s') indexing requires a single integers (for 1D arrays) or sequences, for any rank size", Py_TYPE(self)->tp_name, self->ndim, PyBlitzArray_TypenumAsString(self->type_num));
  return 0;
}
开发者ID:183amir,项目名称:bob.blitz,代码行数:34,代码来源:array.cpp


示例19: pygpgme_context_set_signers

static int
pygpgme_context_set_signers(PyGpgmeContext *self, PyObject *value)
{
    PyObject *signers = NULL;
    int i, length, ret = 0;

    if (value == NULL) {
        PyErr_SetString(PyExc_AttributeError, "Can not delete attribute");
        return -1;
    }

    signers = PySequence_Fast(value, "signers must be a sequence of keys");
    if (!signers) {
        ret = -1;
        goto end;
    }

    gpgme_signers_clear(self->ctx);
    length = PySequence_Fast_GET_SIZE(signers);
    for (i = 0; i < length; i++) {
        PyObject *item = PySequence_Fast_GET_ITEM(signers, i);

        if (!PyObject_TypeCheck(item, &PyGpgmeKey_Type)) {
            PyErr_SetString(PyExc_TypeError,
                            "signers must be a sequence of keys");
            ret = -1;
            goto end;
        }
        gpgme_signers_add(self->ctx, ((PyGpgmeKey *)item)->key);
    }

 end:
    Py_XDECREF(signers);
    return ret;
}
开发者ID:andreimacavei,项目名称:pygpgme,代码行数:35,代码来源:pygpgme-context.c


示例20: Node_from_list

static PyObject * Node_from_list(PyTypeObject *type, PyObject *args)
{
    PyObject *o, *l;
    Py_ssize_t len, i;
    PyObject **arr;
    Node *tree;

    if (!PyArg_ParseTuple(args, "O", &o))
        return NULL;

    l = PySequence_Fast(o, "sequence is required");
    if (!l)
        return NULL;

    len = PySequence_Fast_GET_SIZE(l);
    arr = PySequence_Fast_ITEMS(l);

    if (len < 1) {
        Py_INCREF(Py_None);
        return Py_None;
    } else
        tree = Node__new(type, arr[0], (Node *)Py_None,
                (Node *)Py_None, (Node *)Py_None);

    for (i=1; i<len; i++)
        Node__insert(tree, arr[i]);

    return (PyObject *)tree;
}
开发者ID:manover,项目名称:bintree,代码行数:29,代码来源:avl.c



注:本文中的PySequence_Fast_GET_SIZE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PySequence_GetItem函数代码示例发布时间:2022-05-30
下一篇:
C++ PySequence_Fast函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap