-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
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 ?):
- for better performances
- to simplify maintainability of code
- to use more standard format
One of the solution would be to useGLib.KeyFile()format
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:
- We should benchmark advantages in term of performances of this change
- Maybe it would be better to avoid use of Property in Metadata to simplify API (there's bugs, for example to compare 2 Properties before a resource.set_value('name', Property).
- We would like to add a version to Metadata 1, 2,.... to be compatible with old versions, and migrate gradually.
Metadata
Metadata
Assignees
Labels
No labels