LB Booster
« python dict in JB LB and LBB »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:57am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: python dict in JB LB and LBB  (Read 369 times)
bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx python dict in JB LB and LBB
« Thread started on: Jul 27th, 2016, 09:49am »

Code:
global key$ , value$ , cut$ , lenght
lenght = 20
cut$ = "|"
call store "i" , "mi"
call store "you" , "vi"
call store "he" , "li"
call store "she" , "si"
call store "greating" , "saluton"
call store "it" , "gi"
print dict$( "i" )
print dict$( "you" )
print dict$( "he" )
print dict$( "q" )
print dict$( "she" )
print dict$( "greating" )
print dict$( "it" )
end
sub store k$ , v$
  if instr( key$ , pad$( k$ ) ) then exit sub
  key$ = key$ + pad$( k$ )
  value$ = value$ + v$ + cut$
end sub
function dict$( k$ )
  p = instr( key$ , pad$( k$ ) )
  if p = 0 then
    uit$ = "NOT THERE"
  else
    p = ( p - 1 ) / lenght + 1
    uit$ = word$( value$ , p , cut$ )
  end if
  dict$ = uit$
end function
function pad$( a$ )
  pad$ = left$( a$ + space$( lenght ) , lenght )
end function
 
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: python dict in JB LB and LBB
« Reply #1 on: Jul 27th, 2016, 2:10pm »

This is the sort of program that can benefit from LBB's speed. I modified it to time 1000 sets of dictionary lookups as follows:

Code:
start = time$("ms")
for i = 1 to 1000
  d1$ = dict$( "i" )
  d2$ = dict$( "you" )
  d3$ = dict$( "he" )
  d4$ = dict$( "q" )
  d5$ = dict$( "she" )
  d6$ = dict$( "greating" )
  d7$ = dict$( "it" )
next i
finish = time$("ms")
print finish - start; " ms" 

Results on this relatively slow laptop:

LBB 3.05: 250 ms
LB 4.04/JB 1.01: 1750 ms

So LBB is about 7 times faster in this case.

Richard.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls