From 3474c7c71ab68656aae4c9cebad8e54f959d16fb Mon Sep 17 00:00:00 2001 From: "codeflash-ai[bot]" <148906541+codeflash-ai[bot]@users.noreply.github.com> Date: Sat, 27 Jul 2024 03:56:56 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Speed=20up=20function=20`?= =?UTF-8?q?=5Fget=5Furl=5Ffor=5Fversion`=20by=2029%=20Here's=20an=20optimi?= =?UTF-8?q?zed=20version=20of=20the=20given=20program.=20The=20key=20impro?= =?UTF-8?q?vement=20here=20is=20reducing=20the=20function=20call=20overhea?= =?UTF-8?q?d=20by=20directly=20embedding=20`=5Fget=5Ftarget=5Ffor=5Fversio?= =?UTF-8?q?n`=20logic=20within=20`=5Fget=5Furl=5Ffor=5Fversion`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With this change. 1. `_get_target_for_version` is optimized using a single return statement. 2. `_get_url_for_version` is slightly optimized by inlining the logic, but it does explicitly keep the optimized `_get_target_for_version` function for potential reuse elsewhere. --- python_modules/dagster/dagster/_generate/download.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/python_modules/dagster/dagster/_generate/download.py b/python_modules/dagster/dagster/_generate/download.py index c8edbced3901d..648d990c080ac 100644 --- a/python_modules/dagster/dagster/_generate/download.py +++ b/python_modules/dagster/dagster/_generate/download.py @@ -44,17 +44,12 @@ def _get_target_for_version(version: str) -> str: - if version == "1!0+dev": - target = "master" - else: - target = version - return target + return "master" if version == "1!0+dev" else version def _get_url_for_version(version: str) -> str: - return ( - f"https://codeload.github.com/dagster-io/dagster/tar.gz/{_get_target_for_version(version)}" - ) + target = "master" if version == "1!0+dev" else version + return f"https://codeload.github.com/dagster-io/dagster/tar.gz/{target}" def download_example_from_github(path: str, example: str, version: str):