pygobject / pgi

[Unmaintained: Use PyGObject instead] GTK+ / GObject Introspection Bindings for PyPy.
GNU Lesser General Public License v2.1
74 stars 16 forks source link

GExiv2.Metadata open_buf very slow #21

Open jim-easterbrook opened 8 years ago

jim-easterbrook commented 8 years ago

The GExiv2 metadata library can read data from a file or from image data already in memory. The latter method is very slow when using pgi. The following test program reports an elapsed time of about 3 to 4 milliseconds without pgi, 3 to 4 seconds with! I get similar results with Python 2 or Python 3. (The image file is a full resolution JPEG straight from my EOS 100D DSLR.)

Simple test program:

from __future__ import print_function

import time

import pgi
pgi.install_as_gi()
from gi.repository import GObject, GExiv2

with open('/home/jim/Pictures/from_camera/2015/2015_10_20/IMGc0983.JPG', 'rb') as pf:
    image_data = pf.read()
md = GExiv2.Metadata()
start = time.time()
md.open_buf(image_data)
stop = time.time()
print('Elapsed time', stop - start)