From: Albert C. <sap...@gm...> - 2020-05-16 13:37:37
|
Thank you Jeff. I will hack a bit and test. My solution will consist in removing if/else code and other friction by making different PyIterator subclasses depending on the number of arguments, for 1,2,3,4 arguments. Above 4, the current approach should do. Tests will show whether my intuition is wrong. Best wishes, Albert Missatge de Jeff Allen <ja...@fa...> del dia ds., 16 de maig 2020 a les 14:24: > > Hi Albert: > > I was going to ask for an isolated example, which might still be useful, but if you have a solution, that's even more interesting. > > Either open an issue at bugs.jython.org and attach a patch, or make a PR at https://github.com/jythontools/jython . In the latter case, we will go via a patch because we don't (for now) master the repo at GitHub. > > Actually, that's probably the next action for the project: move to GitHub. > > Jeff Allen > > On 16/05/2020 14:13, Albert Cardona wrote: > > Hi all, > I think I can improve the performance of imap significantly. > Would you take pull requests at https://github.com/jythontools/jython/blob/master/src/org/python/modules/itertools/imap.java ? > Or should one submit patches to the mercurial repository? > Thanks, > Albert > > On May 16, 2020, at 12:09 AM, Albert Cardona <sap...@gm...> wrote: > > Hi all, > > I am seeing severe performance problems when looping over sequences > and invoking a single method on each element of the sequence, both > with a for loop and with an imap + deque maxlen=0 strategy. The > baseline is clojure, which is fully typed and compiled to bytecode. > > The difference is staggering: 500x to 1000x (from about 1 second to 1 > millisecond). > > Here is a script that can run in Fiji: > > https://github.com/acardona/scripts/blob/dev/python/imagej/tests/test_looping_performance_imglib2_setOne.py > > The script creates an ImgLib2 image of width=512, height=512, depth=5, > of type unsigned byte, and then loops over all pixels to invoke the > method "setOne" on each pixel (pixels are presented as wrapped by an > UnsignedByteType object that offers the "setOne" method). There is an > underlying byte[] array of size 512*512*5 to the image. > > Why the enormous difference? Anything that can be done to mitigate this issue? > > Thank you very much. > > Albert > > > > _______________________________________________ > Jython-dev mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-dev |