On Mon, 18 Feb 2013 20:15:28 -0800, Tim Roberts wrote:
> Chris Hinsley <[email protected]> wrote:
>>
>>Is a Python list as fast as a bytearray ?
>
> Python does not actually have a native array type. Everything in your
> program that looked like an array was actually a list.
Actually it does, but you have to import it first, it is not a built-in
data type.
py> import array
py> arr = array.array('f') # array of floats (C singles)
py> arr.append(0.1)
py> arr.append(0.2)
py> print(arr)
array('f', [0.10000000149011612, 0.20000000298023224])
py> arr.append("foo")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: a float is required
See the documentation for array to see the available type-codes.
http://docs.python.org/2/library/array.html
http://docs.python.org/3/library/array.html
As part of the standard library, Jython and IronPython are required to
implement arrays as well (although they don't use C arrays, so the
implementation may be different).
http://www.jython.org/docs/library/array.html
http://ironpython-test.readthedocs.org/en/latest/library/array.html
IronPython also gives you access to .Net arrays, although of course that
is not standard Python:
http://www.ironpython.info/index.php/Typed_Arrays_in_IronPython
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list