Skip to content

Commit

Permalink
class method optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
rlayers authored May 23, 2023
1 parent 04cd9ee commit 0f075aa
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pawpaw/ito.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,16 +397,18 @@ def __setstate__(self, state):
# region JSON

class JsonEncoderStringless(json.JSONEncoder):
def default(self, o: typing.Any) -> dict[str, typing.Any]:
@classmethod
def default(cls, o: typing.Any) -> dict[str, typing.Any]:
return {
'__type__': 'Ito',
'span': o._span,
'desc': o.desc,
'children': [self.default(c) for c in o.children]
'children': [cls.default(c) for c in o.children]
}

class JsonEncoder(json.JSONEncoder):
def default(self, o: typing.Any) -> dict[str, typing.Any]:
@classmethod
def default(cls, o: typing.Any) -> dict[str, typing.Any]:
return {
'__type__': 'typing.Tuple[str, Ito]',
'string': o.string,
Expand Down

0 comments on commit 0f075aa

Please sign in to comment.