does python could support sequence of short or int?

Mirco Wahab peace.is.our.profession at gmx.de
Thu Mar 30 07:49:51 EST 2006


Hi momobear

> then how can I convert it to a int list? I read about struct and array,
> I think they are not suitable, since I don't know how long will the
> buffer is. I know if I write a plugins modules in C should works, but
> that's really upset to tell to myself there is no way in Python.

this was imho a typical non-problem in
"scripting languages" - regarding the
areas where they are usually employed.

there are some good exensions for Python,
numarray and numpy and so on ...
(http://numeric.scipy.org/)

These provide C-like arrays and
allow you writing programs entirely
in Python w/C-speed on arrays.

interesting: Perl6 will be the first
(afaik) scripting language w/"type arrays"
build into the core language
e.g.
 sub hist(Int @vals) returns Array of Int {
      my Int @histogram;
      for @vals { @histogram[$_]++ }
      return @histogram;
    }
(from http://www.jauu.net/data/foils/perl6/perl_6.html)

Regards,

M.



More information about the Python-list mailing list