@@ -133,8 +133,8 @@ def __init__(self, display=None):
133133 if isfile (libmss ):
134134 self .mss = cdll .LoadLibrary (libmss )
135135 self .use_mss = True
136- else :
137- print ('No MSS library found. Using slow native function.' )
136+ # else:
137+ # print('No MSS library found. Using slow native function.')
138138
139139 self ._set_argtypes ()
140140 self ._set_restypes ()
@@ -285,7 +285,10 @@ def get_pixels(self, monitor):
285285
286286 def get_pixels_slow (self , ximage ):
287287 ''' Retrieve all pixels from a monitor. Pixels have to be RGB.
288- (!) Insanely slow version, see doc/linux-slow-version. (!)
288+
289+ (!) This version is damn slow, but if you consider that ~1 second
290+ for a screenshot of decent monitor is not too long, you can
291+ continue. There should be few things to tweak here to gain speed.
289292 '''
290293
291294 # @TODO: this part takes most of the time. Need a better solution.
@@ -296,11 +299,13 @@ def pix(pixel, _resultats={}, p__=pack):
296299
297300 # pylint: disable=dangerous-default-value
298301
299- if pixel not in _resultats :
302+ try :
303+ return _resultats [pixel ]
304+ except KeyError :
300305 _resultats [pixel ] = p__ ('<B' , (pixel & rmask ) >> 16 ) + \
301306 p__ ('<B' , (pixel & gmask ) >> 8 ) + \
302307 p__ ('<B' , pixel & bmask )
303- return _resultats [pixel ]
308+ return _resultats [pixel ]
304309
305310 self .width = ximage .contents .width
306311 self .height = ximage .contents .height
0 commit comments