That one is the fastest in the profiler too. I'll attach the text file so you can see the results yourself. The handlers are listed in order of speed results, I believe.
Params to Python external script?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 7230
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Params to Python external script?
- Attachments
-
- scriptProfile-grayscale.txt.zip
- (35.68 KiB) Downloaded 106 times
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Params to Python external script?
Thank you very much Jacqueline
Your very accurate results confirm that, in that script, repeat for... step 4 is the fastest solution.
@Bernard: I tried byteToNum() and it's indeed a little bit faster. Thanks for the tip!
Though, there is still a very strange thing that I really don't understand.
and only set a new alphaData, the result is good.
Maybe I don't well understand how imageData and alphaData work in internal.
Your very accurate results confirm that, in that script, repeat for... step 4 is the fastest solution.
@Bernard: I tried byteToNum() and it's indeed a little bit faster. Thanks for the tip!
Though, there is still a very strange thing that I really don't understand.
I don't need to modify imageData: if I comment the following line
Code: Select all
set the imageData of image pixDestName to tImage
Maybe I don't well understand how imageData and alphaData work in internal.
Re: Params to Python external script?
It bothered me that I was seeing results that made no sense. Zax has found an anomaly.
(where in the loop bytes i+1, i+2, i+3 are then addressed - so this is NOT just a question of the size of x being x/4)
is faster than
but only when "step 4" is used. I guess someone who knows the innards of LC better than me would have an explanation.
Code: Select all
repeat with i = 1 to the number of bytes in x step 4
is faster than
Code: Select all
repeat for each byte in x
Bernard wrote: ↑Thu Jul 15, 2021 11:02 amI spent a lot of time running tests and writing the results here. When I went to post, the stupid forum software/setup demanded I login again. I did so and all my work was lost.
What kind of design trashes a user's work like that?
My tests revealed lots of contradictory results (some back up Zax claims and contradict Jacque's profiling, others back up my expectations). I really can't be bothered to spend more of my time on this when the forum is so badly designed.
Code: Select all
repeat for each ... byteToNum() 3,108 ms repeat for each... charToNum() 3,356 ms repeat with ... the number of chars... charToNum() 25,631 ms repeat with ... the number of bytes in... byteToNum() 3,169 ms
-
- VIP Livecode Opensource Backer
- Posts: 7230
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Params to Python external script?
I don't know how it works internally either but when using "step" it seems to act like "for each". That makes me think that step has to set a pointer in order to count each step, which is what "for each" does too. But we'd need someone who can read the source code to verify.
BTW, I've lost posts too in the past. I learned to either copy my text to the clipboard before leaving the page, or save a draft if I won't be back for a while.
BTW, I've lost posts too in the past. I learned to either copy my text to the clipboard before leaving the page, or save a draft if I won't be back for a while.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Params to Python external script?
Code: Select all
when using "step" it seems to act like "for each"
Still, I'm glad that I kept going until I had an explanation, even if it doesn't help Zax with his problem.
-
- VIP Livecode Opensource Backer
- Posts: 7230
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Params to Python external script?
Okay, that's weird. I have no clue.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Params to Python external script?
Finally, I wrote a little Python script to process images with Pillow library. It works fine and it's very fast
At the start of the project, I didn't want to use a library that required be be installed deeply in the core of the OS but I recently realized that it was possible to use the Pillow library placed in any folder once it has been unzipped, so I put the Pillow folder inside my standalone folder.
If one is interested, I can post my Python script (at this time, it has only been tested on Mac: I think it requires some little modifications to work on Windows, concerning file pathes. Of course, Python have to be installed in the OS (it is pre-installed on MacOS, as PHP).
At the start of the project, I didn't want to use a library that required be be installed deeply in the core of the OS but I recently realized that it was possible to use the Pillow library placed in any folder once it has been unzipped, so I put the Pillow folder inside my standalone folder.
If one is interested, I can post my Python script (at this time, it has only been tested on Mac: I think it requires some little modifications to work on Windows, concerning file pathes. Of course, Python have to be installed in the OS (it is pre-installed on MacOS, as PHP).
Re: Params to Python external script?
I'm glad it works. I guess you are writing the image out to a file then having Python process the file?
Re: Params to Python external script?
Yes, something like that: instead of reading the image file with LC, I send its file path to Python. Python loads the image, modify it, save modified image as temporary file and returns this temporary file path to LC, in order to display the modifed image in a stack.
I was able to finalize this stack: viewtopic.php?f=7&t=35908
Re: Params to Python external script?
That's cool. Scott Raney, the man behind Metacard (the origin of Livecode), used to often cite Metacard as superior to Tcl. Tcl was famously conceived of and known as "a glue language", designed to coordinate/integrate input/output of other programmes.
Re: Params to Python external script?
The way LC is opened to Applescript, shell and Python is very very convenient
I suppose building externals widely extends LC but I'm not skilled enough to build such things.
I suppose building externals widely extends LC but I'm not skilled enough to build such things.