hforge / itools

Python library with tons of features
http://www.hforge.org/itools
GNU General Public License v3.0
22 stars 12 forks source link

Study change of Metadata format #97

Open staverne opened 7 years ago

staverne commented 7 years ago

We've started to refactor Metadata and MetadataProperty, in a previous version, to avoid the use of complex ical format for metadata files. We would like to use a more efficient parser (in C ?):

from gi.repository import GLib

N = 20000

metadata_str = """
[default]
String=mystr
Bool=true
Int=300
Double=0.0
"""

for i in range(N):
    a = GLib.KeyFile()
    a.load_from_data(metadata_str, len(metadata_str), GLib.KeyFileFlags.NONE)
    a.get_value('default', 'String')
    a.set_string_list('default', 'multiple', ['1', '2', '3'])
    a.set_locale_string('default', 'title', 'fr', u'Hello')
    a.set_locale_string('default', 'title', 'en', u'Hello')
    a.save_to_file('/tmp/%s.metadata' % i)
    a.to_data()

for i in range(N):
    a = GLib.KeyFile()
    a.load_from_file('/tmp/%s.metadata' % i, GLib.KeyFileFlags.NONE)
    a.to_data()

Some remarks:

jdavid commented 7 years ago

May I suggest to use JSON? Widely used, more powerful. Or YAML which is more human readable.