Lutz,
That's a helpful use of the function to know about, but that still doesn't give me a real performance boost. Exploding the string is too expensive.
Is there no way to iterate quickly over the chars in a string? What is newLisp's internal representation of a string like? If there isn't a way to do so, could a dostring function be added?
Also, I tried to import my C library I used with Python to do the work for me and had some real difficulty. Here is the C lib:
Code: Select all
#include <stdio>
#include <stdlib>
#include <string>
#define CHARS 128
typedef struct tally
{
char *text;
int counts[CHARS];
} TALLY;
TALLY init_counts(char *str);
void count_chars(TALLY *t);
int count_of_char(TALLY *t, char c);
TALLY init_count(char *str)
{
int i;
TALLY t;
t.text = str;
for (i = 0; i < CHARS; i++)
{
t.counts[i] = 0;
}
count_chars(&t);
return t;
}
void count_chars(TALLY *t)
{
int i;
for (i = 0; i <strlen>text); i++)
{
t->counts[(int) t->text[i]]++;
}
}
int count_of_char(TALLY *t, char c)
{
return t->counts[(int) c];
}
After importing init_counts, I run (set 'foo (init_counts very-large-string)). This does not seem to work at all. I get nothing back and the action hangs. I also tried a C function that only takes a string and prints the first 100 chars, just to test the newLisp code, and it seems like passing a string to a library function takes an inordinate amount of time (which is why I was wondering about newLisp's internal string representation).
Any ideas? I would love to get rid of python's overhead in my app by using newLisp and additionally have the ability to run the software in an easy-to-create gui, but 3.5 seconds is way too expensive here.