|
From: Robert W. B. <rb...@di...> - 2001-06-22 20:08:55
|
Hello Jarrett,
"10 100" doesn't autoconvert to an array. More below...
On Fri, 22 Jun 2001, W. Jarrett Campbell wrote:
> Hello. I've been using Python for a short while and one of my developers is
> insisting he'd prefer to supply me with Java classes rather than C++ classes
> so I'm contemplating making the jump to Jython.
>
> We were running a simple benchmark test to see if we could this system
> working for us and I've encountered a few problems. Could someone here give
> me a few pointers?
>
> I'm trying to execute the following method in Jython:
>
> public static void main(String[] args) {
>
> try {
> int count = Integer.parseInt(args[0]);
> int arraySize = Integer.parseInt(args[1]);
>
> ArrayBenchmark test = new ArrayBenchmark();
> test.setLength( arraySize );
>
> long totalTime = test.repeat(count);
> System.out.println("Array Benchmark: " + count + " iteration(s) in "
> + totalTime + " milliseconds");
> } catch (Exception e) {
> System.out.println("Exception: " + e);
> e.printStackTrace();
> }
> }
>
> Every time I execute this command, I get a message that the String coercion
> is failing. Any ideas?
>
> >>> com.ydyn.dynamo.test.ArrayBenchmark.main('10 100')
> Traceback (innermost last):
> File "<console>", line 1, in ?
> TypeError: main(): 1st arg can't be coerced to String[]
> >>>
"10 100" becomes a String, not a String[]. Jython's nifty little tricks
allow you to use a Python List (PyList class) type full 'o strings to auto
convert to a String[].
i.e.:
>>> com.ydyn.dynamo.test.ArrayBenchmark.main(['10000000', '100'])
Array benchmark: 10000000 iterations in ...
-robert
|