Skip to content

Commit

Permalink
Perform version check at compile time.
Browse files Browse the repository at this point in the history
This is a small performance optimization.
  • Loading branch information
aaugustin committed Nov 1, 2022
1 parent 17d5d41 commit 077e642
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/websockets/legacy/compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@
from typing import Any, Dict


def loop_if_py_lt_38(loop: asyncio.AbstractEventLoop) -> Dict[str, Any]:
"""
Helper for the removal of the loop argument in Python 3.10.
if sys.version_info[:2] >= (3, 8):

"""
return {"loop": loop} if sys.version_info[:2] < (3, 8) else {}
def loop_if_py_lt_38(loop: asyncio.AbstractEventLoop) -> Dict[str, Any]:
"""
Helper for the removal of the loop argument in Python 3.10.
"""
return {}

else: # pragma: no cover

def loop_if_py_lt_38(loop: asyncio.AbstractEventLoop) -> Dict[str, Any]:
"""
Helper for the removal of the loop argument in Python 3.10.
"""
return {"loop": loop}

0 comments on commit 077e642

Please sign in to comment.