As I have mention in other thread I have some ideas about how can be 
improved Leo code that deals with the configuration and user settings.

Using small python script I have collected all settings from 
leoSettings.leo and created a dictionary whose keys are types of settings 
(int, ratio, float, string, color, bool and data) and values are lists of 
setting names.

Then I made list of all possible pairs (type, setting-name) and for each 
pair I put the current value in sqlite3 database table.

For each pair I have checked that the value returned by corresponding 
c.config.get<Type>(name) method is the same one that is returned by sql 
query for given settings name.

Then I have tested using timeit module, both methods of reading settings 
and the result is that using sqlite to retrieve settings value is actually 
faster then using plain c.config module. Speed gain is small, just about 
12.4%, but at least experiment proved that using sqlite for dealing with 
configuration is possible. 

What would be the benefits if Leo configuration code use database to store 
and retrieve settings. I believe that Leo startup code could be greatly 
simplified if the settings are available just by opening a database 
connection. There is no need to postpone any initialization because 
settings haven't been fully read yet. I have tried several times to 
understand what exactly is going on during initialization but I gave up 
every time because it was nightmare of indirect calls, halfway 
initialization, ... Almost all important members are initialized twice or 
more times. Once with the simple or dummy value, and later reinitialized 
with the correct one. Because of that there are everywhere checks if some 
dict is properly initialized or not. Arguably all that stuff could be 
written much simpler if c.config was present at the very beginning of the 
execution process. 

Attached to this message is sqlite3-config-benchmark.leo. Executing the 
script in its first node, performs all the steps I wrote about and prints 
in Log pane times for retrieving value of every setting 1000 times. On my 
computer it take about 6.5 s for c.config and 5.5 s for sqlite3 to give all 
those values. 

I am not so good in programming PyQt gui, but if all settings are kept in 
sqlite database, I could easily make single page web application and 
minimal REST server for accessing/adjusting all settings in web browser. 
Leo would need just one simple command to open local url in users default 
browser and user would be able to tweak any and all of the settings in 
browser. Server could be implemented in python and may actually run in the 
same Leo process or in other separate process. Leo would be aware of any 
such change in settings immediately. It would not be necessary to restart 
Leo to see changes. Maybe some of the changes would require restart, but 
most of them IMHO would not.
Vitalije

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Attachment: sqlite3-config-benchmark.leo
Description: Binary data

Reply via email to