Skip to content

Commit

Permalink
journal: remove ChainMap
Browse files Browse the repository at this point in the history
"after some quick testing, the execution time got halved (32-ish
seconds to 16-ish seconds) when going through all journal entries."

Closes #63.
  • Loading branch information
Glandos authored and keszybz committed Nov 12, 2020
1 parent 9cbc4e9 commit 2166b57
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions systemd/journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import logging as _logging
from syslog import (LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR,
LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG)
if _sys.version_info >= (3,3):
from collections import ChainMap as _ChainMap

from ._journal import __version__, sendv, stream_fd
from ._reader import (_Reader, NOP, APPEND, INVALIDATE,
Expand Down Expand Up @@ -172,15 +170,9 @@ def __init__(self, flags=None, path=None, files=None, converters=None, namespace
flags = 0

super(Reader, self).__init__(flags, path, files, namespace)
if _sys.version_info >= (3, 3):
self.converters = _ChainMap()
if converters is not None:
self.converters.maps.append(converters)
self.converters.maps.append(DEFAULT_CONVERTERS)
else:
self.converters = DEFAULT_CONVERTERS.copy()
if converters is not None:
self.converters.update(converters)
self.converters = DEFAULT_CONVERTERS.copy()
if converters is not None:
self.converters.update(converters)

def _convert_field(self, key, value):
"""Convert value using self.converters[key].
Expand Down

0 comments on commit 2166b57

Please sign in to comment.