Ejemplo n.º 1
0
// NewList creates a new Python List instance.  The created list has initial
// length "size".
//
// Note: If size > 0, then the objects in the returned list are initialised to
// nil.  Thus you cannot use Abstract API functions, or expose the object to
// Python code without first filling in all the created slots with
// list.SetItem().
//
// Return value: New Reference.
func NewList(size int64) (*List, error) {
	ret := C.PyList_New(C.Py_ssize_t(size))
	if ret == nil {
		return nil, exception()
	}
	return newList(ret), nil
}
Ejemplo n.º 2
0
Archivo: list.go Proyecto: z0mbie42/py3
func NewList(size int) *List {
	return (*List)(PyObjectToGO(C.PyList_New(C.Py_ssize_t(size))))
}
Ejemplo n.º 3
0
// PyObject* PyList_New(Py_ssize_t len)
// Return value: New reference.
// Return a new list of length len on success, or NULL on failure.
//
// Note If length is greater than zero, the returned list object’s items are set to NULL. Thus you cannot use abstract API functions such as PySequence_SetItem() or expose the object to Python code before setting all items to a real object with PyList_SetItem().
// Changed in version 2.5: This function used an int for size. This might require changes in your code for properly supporting 64-bit systems.
func PyList_New(sz int) *PyObject {
	return togo(C.PyList_New(C.Py_ssize_t(sz)))
}