# Feature or enhancement ### Proposal: Currently both implemenatations of `relpath()` are a bit inefficient. So they could use some optimisations: 1. We don't need to apply `normpath()` before `abspath()`, it already normalises it: ```diff -start_abs = abspath(normpath(start)) -path_abs = abspath(normpath(path)) +start_abs = abspath(start) +path_abs = abspath(path) ``` 2. We don't need to filter the segments, we just need to check if `*_rest` is empty: ```diff -start_list = [x for x in start_rest.split(sep) if x] -path_list = [x for x in path_rest.split(sep) if x] +start_list = start_rest.split(sep) if start_rest else [] +path_list = path_rest.split(sep) if path_rest else [] ``` 3. We can use `str.join()` instead of `os.path.join()`: ```diff -return join(*rel_list) +return sep.join(rel_list) ``` ### Has this already been discussed elsewhere? This is a minor feature, which does not need previous discussion elsewhere ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-117608 <!-- /gh-linked-prs -->