I did a lot of testing for this as I need to keep a dictionary of words identified by word IDs with some 300 000 items around. I need to retrieve the words based on their ID. Using objects was MAGNITUDES faster than synchronised arrays (Cannot find the number anymore but we are talking measurable differences here, 1ms to several hundred), so I immediately trashed the old array based code and rewrite with objects. Never looked back :-)
Cheers Alex > Am 17.07.2017 um 12:46 schrieb Peter Jakobsson via 4D_Tech > <4d_tech@lists.4d.com>: > > Hi > > I remember at last year’s summit, JPR was emphasising how objects were far > more optimised than arrays for doing lookups over large numbers of key value > pairs. > > e.g. we usually do this: > > $x:=find in array(myKEYS;”product_code_x”) > > if($x>0) > $0:=myPRICES{$x} > end if > > How do people prefer to do this with objects ? Enumerate the keys in some > systematic way and then populate the object like this > > > For($i;1;$SIZE) > > $key:=string($i) > $value:=myarrayVAL{$i} > OB SET($object;$key;$value) > > End For > > Then for retreiving: > > $key:=string($1) > > $0:=OB Get($object;$key) > > …or was JPR suggesting we use object arrays and do some kind of “find” over > the object arrays ? > > Best Regards > > Peter > > ********************************************************************** > 4D Internet Users Group (4D iNUG) > FAQ: http://lists.4d.com/faqnug.html > Archive: http://lists.4d.com/archives.html > Options: http://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ********************************************************************** ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **********************************************************************