All Samples(41) | Call(39) | Derive(0) | Import(2)
Pack the values v1, v2, ... according to fmt. Write the packed bytes into the writable buffer buf starting at offset.
src/p/y/pypy3-HEAD/pypy/lib/array.py pypy3(Download)
array(typecode [, initializer]) -- create a new array """ from struct import calcsize, pack, pack_into, unpack_from import operator # the buffer-like object to use internally: trying from
if not (0 <= i < seqlength):
raise IndexError(i)
boundary = i * self.itemsize
pack_into(self.typecode, self._data, boundary, x)
def __setslice__(self, i, j, x):
self.__setitem__(slice(i, j), x)
def _fromiterable(self, iterable):
iterable = tuple(iterable)
n = len(iterable)
boundary = len(self._data)
newdata = bytebuffer(boundary + n * self.itemsize)
newdata[:boundary] = self._data
pack_into('%d%s' % (n, self.typecode), newdata, boundary, *iterable)
src/p/y/pypy-HEAD/lib_pypy/array.py pypy(Download)
array(typecode [, initializer]) -- create a new array """ from struct import calcsize, pack, pack_into, unpack_from import operator # the buffer-like object to use internally: trying from
if not (0 <= i < seqlength):
raise IndexError(i)
boundary = i * self.itemsize
pack_into(self.typecode, self._data, boundary, x)
def __setslice__(self, i, j, x):
self.__setitem__(slice(i, j), x)
def _fromiterable(self, iterable):
iterable = tuple(iterable)
n = len(iterable)
boundary = len(self._data)
newdata = bytebuffer(boundary + n * self.itemsize)
newdata[:boundary] = self._data
pack_into('%d%s' % (n, self.typecode), newdata, boundary, *iterable)