11
I am trying to figure out if it is better to use:
os.path.join(str1, str2)
or:
str1 + os.sep + str2
Profiling with timeit I found that, as expected, concatenation is faster:
%timeit 'playground' + os.sep + 'Text'
10000000 loops, best of 3: 139 ns per loop
%timeit os.path.join('playground', 'Text')
1000000 loops, best of 3: 830 ns per loop
So my question is, since concatenation is also shorter, is there a reason to use os.path.join(()?
Thanks