BASIC Developer & Support Resources => Scripting Languages => Topic started by: John on April 28, 2015, 08:28:37 PM

Title: Elastic String Array
Post by: John on April 28, 2015, 08:28:37 PM
I have been following the Elastic String Array (,4859.0.html) thread and just want to mention that I haven't found ANY language that is more flexible than Script BASIC arrays. I challenge anyone to prove me wrong.

Script BASIC Array Tutorial (,170.0.html)
Title: Re: Elastic String Array
Post by: John on April 28, 2015, 09:44:29 PM
Quote from: AIR
Quote from: aurelB
so nothing will stop you...
create program in py which build a$[1000000]
then fill each element with just one char
and tell us how much time python need for that.
simple isn't?

Yes, simple indeed:

Code: Python
  1. #!/usr/bin/env python
  2. arr = ['c']*1000000

[riveraa@Blossom ~] $ time ./

real   0m0.059s
user   0m0.033s
sys   0m0.021s

MacBook Pro laptop, 2.53 GHz Intel Core 2 Duo, 4GB ram, 250GB 5400 RPM mechanical drive

Here is AIR's Python example on my laptop.

jrs@laptop:~/python$ time ./

real   0m0.971s
user   0m0.030s
sys   0m0.020s

Here is the Script BASIC execution time on my laptop.

Code: Script BASIC
  1. SPLITA STRING(1000000,"C") BY "" TO a
  2. PRINT UBOUND(a)," : ",a[UBOUND(a)],"\n"

jrs@laptop:~/sb/sb22/test$ time scriba
999999 : C

real   0m0.298s
user   0m0.177s
sys   0m0.120s

Title: Re: Elastic String Array
Post by: John on April 28, 2015, 10:37:21 PM
Quote from: Aurel
and here we go:

Arrays in basic Python are actually lists that can contain mixed datatypes. However, the numarray module contains support for true arrays, including multi-dimensional arrays, as well as IDL-style array operations and the where function. To use arrays, you must import numarray or from numarray import *. Unfortunately, numarray generally only suports numeric arrays. Lists must be used for strings or objects. By importing numarray.strings and numarray.objects, you can convert string and object lists to arrays and use some of the numarray features, but only numeric lists are fully supported by numarray.

so what is that ?
there is no real array in python core than list?
well so it seems that Armando fill list of pointers?
and if you wish real array you depend on external modules   ::)


Quote from: bestofqbasic
(you mean you NEVER wanted option to mix strings and numerics in an array? never?)

I could NEVER go back to a language that doesn't support mixed type arrays.