FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Get rid of _EventBundle by bluetech · Pull Request #118 · python-hyper/h11 · GitHub

Get rid of _EventBundle - #118

Closed
bluetech wants to merge 2 commits into
python-hyper:masterfrom
bluetech:unbundle
Closed

Get rid of _EventBundle#118
bluetech wants to merge 2 commits into
python-hyper:masterfrom
bluetech:unbundle

Conversation

Copy link
Copy Markdown
Contributor

This is based on #116 so you can ignore the first commit.

_EventBundle uses a lot of dynamic python features to save on some duplication, but it slows things down, and will also make it much harder to add static typing. Since these types are now pretty stable, it seems not worth it.

On the bench/ micro-benchmark:

Before:  9322.6 requests/sec
After : 10544.6 requests/sec

_EventBundle uses a lot of dynamic python features to save on some
duplication, but it slows things down, and will also make it much harder
to add static typing. Since these types are now pretty stable, it seems
not worth it.

On the bench/ micro-benchmark:

Before:  9322.6 requests/sec
After : 10544.6 requests/sec

Copy link
Copy Markdown
Contributor Author

@pgjones if this conflicts with something you're doing let me know! (In #114 you mentioned converting to dataclasses, but these require py37 and I personally prefer to avoid them in public library API).

pgjones commented Nov 18, 2020

Copy link
Copy Markdown
Member

I'm happy with this, I've no strong attachment to dataclasses. I'm minded to merge after #116.

sethmlarson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Seems good to me, one question:

Comment thread h11/_state.py


class ConnectionState(object):
class ConnectionState:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Should we use __slots__ for this object as well since it's accessed frequently?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm in favor of adding slots to everything personally. I'll do it in a separate PR after some of the others are settled.

Comment thread h11/_events.py
_defaults = {"http_version": b"1.1", "reason": b""}
# Useful for tests
def __eq__(self, other):
if not isinstance(other, type(self)):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Whilst this changes the logic of what is equal or not (from self.__class__ == other.__class__) to include subclasses and potentially raising if incompatible classes are compared (rather than returning False) I think it is fine as this is mostly (and likely only) used for tests.

pgjones commented Dec 26, 2020

Copy link
Copy Markdown
Member

Having said I've no attachment to dataclasses; what do you think of the usage of frozen as in wsproto? I think that better clarifies the API for these objects.

Copy link
Copy Markdown
Member

I'm +1 on using dataclasses and frozen.

pgjones commented Dec 27, 2020

Copy link
Copy Markdown
Member

See #124 as the dataclass alternative.

pgjones commented May 16, 2021

Copy link
Copy Markdown
Member

I've merged the dataclass approach for the reasons discussed, plus that we have a desire to use dataclasses consistently in the hyper projects.

pgjones closed this May 16, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL