Skip to content

Commit

Permalink
CR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
roxanneskelly committed Sep 7, 2023
1 parent c5e41c8 commit 2432466
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion llsd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def _array_to_python(node, depth=0):
def _to_python(node, depth=0):
"Convert node to a python object."
if depth > MAX_PARSE_DEPTH:
raise LLSDParseError("Cannot parse depth of more than %d" % MAX_FORMAT_DEPTH)
raise LLSDParseError("Cannot parse depth of more than %d" % MAX_PARSE_DEPTH)

return NODE_HANDLERS[node.tag](node, depth)

Expand Down
20 changes: 10 additions & 10 deletions llsd/serde_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,18 @@ def _UUID(self, v):
self.stream.writelines([b'<uuid>', str(v).encode('utf-8'), b'</uuid>', self._eol])
def _BINARY(self, v):
self.stream.writelines([b'<binary>', base64.b64encode(v).strip(), b'</binary>', self._eol])
def _STRING(self, v):
# We don't simply have a function that encapsulates the PY2 vs PY3 calls,
# as that results in another function call and is slightly less performant
if PY2: # pragma: no cover

if PY2:
def _STRING(self, v):
return self.stream.writelines([b'<string>', _str_to_bytes(xml_esc(v)), b'</string>', self._eol])
self.stream.writelines([b'<string>', v.translate(XML_ESC_TRANS).encode('utf-8'), b'</string>', self._eol])
def _URI(self, v):
# We don't simply have a function that encapsulates the PY2 vs PY3 calls,
# as that results in another function call and is slightly less performant
if PY2: # pragma: no cover
def _URI(self, v):
return self.stream.writelines([b'<uri>', _str_to_bytes(xml_esc(v)), b'</uri>', self._eol])
self.stream.writelines([b'<uri>', str(v).translate(XML_ESC_TRANS).encode('utf-8'), b'</uri>', self._eol])
else:
def _STRING(self, v):
self.stream.writelines([b'<string>', v.translate(XML_ESC_TRANS).encode('utf-8'), b'</string>', self._eol])
def _URI(self, v):
self.stream.writelines([b'<uri>', str(v).translate(XML_ESC_TRANS).encode('utf-8'), b'</uri>', self._eol])

def _DATE(self, v):
self.stream.writelines([b'<date>', _format_datestr(v), b'</date>', self._eol])
def _ARRAY(self, v):
Expand Down

1 comment on commit 2432466

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Python Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.10.

Benchmark suite Current: 2432466 Previous: a63abbe Ratio
tests/bench.py::test_format_notation 23056.689642438265 iter/sec (stddev: 0.00001241726135366824) 26326.55225540916 iter/sec (stddev: 0.000011888050812629382) 1.14

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.