-
Notifications
You must be signed in to change notification settings - Fork 284
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
perf: speedup date parsing using ciso8601 #590
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ | |
|
||
from traitlets.config.configurable import Configurable, LoggingConfigurable | ||
from ipython_genutils.importstring import import_item | ||
from jupyter_client.jsonutil import extract_dates, squash_dates, date_default | ||
from jupyter_client.jsonutil import extract_dates, squash_dates, date_default, parse_date | ||
from ipython_genutils.py3compat import str_to_bytes, str_to_unicode | ||
from traitlets import ( | ||
CBytes, Unicode, Bool, Any, Instance, Set, DottedObjectName, CUnicode, | ||
|
@@ -928,10 +928,14 @@ def deserialize(self, msg_list, content=True, copy=True): | |
if not len(msg_list) >= minlen: | ||
raise TypeError("malformed message, must have at least %i elements"%minlen) | ||
header = self.unpack(msg_list[1]) | ||
message['header'] = extract_dates(header) | ||
|
||
message['header'] = header | ||
message['header']['date'] = parse_date(message['header']['date']) | ||
message['msg_id'] = header['msg_id'] | ||
message['msg_type'] = header['msg_type'] | ||
message['parent_header'] = extract_dates(self.unpack(msg_list[2])) | ||
message['parent_header'] = self.unpack(msg_list[2]) | ||
if 'date' in message['parent_header']: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will break current stable ipyparallel, which currently relies on the behavior of parsing any date-like strong, but I can deal with that. I never should have made it find and parse any valid date objects! I suspect that parsing just the date will break exactly as many things as disabling parsing entirely, though. Which is to say: ipyparallel and probably nothing else. |
||
message['parent_header']['date'] = parse_date(message['parent_header']['date']) | ||
message['metadata'] = self.unpack(msg_list[3]) | ||
if content: | ||
message['content'] = self.unpack(msg_list[4]) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pytest | ||
|
||
from jupyter_client import session as ss | ||
|
||
from .test_session import SessionTestCase | ||
|
||
@pytest.mark.usefixtures('benchmark') | ||
class TestPerformance(SessionTestCase): | ||
@pytest.fixture(autouse=True) | ||
def _request_benchmark(self, benchmark): | ||
self.benchmark = benchmark | ||
|
||
def test_deserialize_performance(self): | ||
def run(data): | ||
self.session.digest_history = [] | ||
self.session.deserialize(self.session.feed_identities(data)[1]) | ||
content = dict(t=ss.utcnow()) | ||
metadata = dict(t=ss.utcnow()) | ||
self.session.auth = None | ||
p = self.session.msg('msg') | ||
msg = self.session.msg('msg', content=content, metadata=metadata, parent=p['header']) | ||
data = self.session.serialize(msg) | ||
self.benchmark(run, data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be added to the existing
pip install
, one step above, instead of being part of the test stage?