1 package org.python.modules; 3 4 import org.python.core.*; 5 6 9 public class ArrayModule { 10 11 public static PyString __doc__ = new PyString( 12 "This module defines a new object type which can efficiently represent\n" + 13 "an array of basic values: characters, integers, floating point\n" + 14 "numbers. Arrays are sequence types and behave very much like lists,\n" + 15 "except that the type of objects stored in them is constrained. The\n" + 16 "type is specified at object creation time by using a type code, which\n" + 17 "is a single character. The following type codes are defined:\n" + 18 "\n" + 19 " Type code C Type Minimum size in bytes \n" + 20 " 'z' boolean 1 \n" + 21 " 'c' character 1 \n" + 22 " 'b' signed integer 1 \n" + 23 " 'h' signed integer 2 \n" + 25 " 'i' signed integer 2 \n" + 27 " 'l' signed integer 4 \n" + 29 " 'f' floating point 4 \n" + 31 " 'd' floating point 8 \n" + 32 "\n" + 33 "Functions:\n" + 34 "\n" + 35 "array(typecode [, initializer]) -- create a new array\n" + 36 "\n" + 37 "Special Objects:\n" + 38 "\n" + 39 "ArrayType -- type object for array objects\n" 40 ); 41 42 public static PyString __name__ = new PyString("array"); 43 44 47 48 public static PyArray ArrayType(char TypeCode) { 49 return PyArray.array(new PyList(), TypeCode); 50 } 51 52 public static PyObject ArrayType(char TypeCode, PyObject sequence) { 53 return PyArray.array(sequence, TypeCode); 54 } 55 56 public static PyObject array(char TypeCode) { 57 return PyArray.array(new PyList(), TypeCode); 58 } 59 60 public static PyObject array(char TypeCode, PyObject sequence) { 61 return PyArray.array(sequence, TypeCode); 62 } 63 64 69 70 public static PyArray array(Class type, PyObject seq) { 71 return PyArray.array(seq, type); 72 } 73 74 public static PyArray zeros(char typecode, int n) { 75 return PyArray.zeros(n, typecode); 76 } 77 78 public static PyArray zeros(Class type, int n) { 79 return PyArray.zeros(n, type); 80 } 81 } 82 | Popular Tags |