Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Study change of Metadata format #97

Open
staverne opened this issue May 5, 2017 · 1 comment
Open

Study change of Metadata format #97

staverne opened this issue May 5, 2017 · 1 comment

Comments

@staverne
Copy link
Member

staverne commented May 5, 2017

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 use GLib.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.
@jdavid
Copy link
Member

jdavid commented May 5, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants