Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Why is large dictionary slowing editing to 1 key press every 30 secs on iPad 3?
-
Hi
Using Pythonista on an iPad 3.
Rather than read from a file I copied/pasted some data into a dict() so that the code would be standalone. It has approx 100 keys, each with 8 values. Now when I try to edit the details in the dict() it takes about 30 seconds for each key press, and scrolling takes time too.
Can someone suggest why this happens, or an alternative format for the data in my code?
The script is a very short, only about 30 lines, and is a simple search / lookup that I have been using to practice my python coding so this was surprising. I wondered whether it is constantly recompiling the code or something like that...
Thanks. -
I'd recommend splitting the dict into more lines; the editor can get pretty slow with very long lines because of the syntax highlighting etc. (when you change a line, it has to be parsed again completely).
E.g. instead of this:
my_dict = {'foo': 'bar', 'baz': 'quuz', 'spam': 'eggs', ... }
...try something like this:
my_dict = {'foo': 'bar', 'baz': 'quuz', 'spam': 'eggs', ...}
(doesn't make much of a difference in this simple case, but for a large dict it will improve editing performance.
-
You might try turning off the jedi autocomplete in the options. You might also consider reading from a file. Using the gistcheck scripts, you can easily get data in and out of pythonista, so there is not necessarily a good reason to try to keep everything in one file. This could even just be an execfile if you don't want to deal with marshal or pickle.
-
Thanks for the suggestions. Separate lines has worked a treat. Simple and effective.
Trying options with and without accessing file - haven't made up my mind exactly how I see the code going ahead.Question answered - tick.