nigma/django-easy-pjax — pull request #2 by pagenoare (2013-05-25 11:41:38+00:00)
Title: code improvement

i believe this is cleaner & faster:

In [1]: def x(a, t='ajax.html'):
...: parts = [name.strip() for name in a.split(",")]
...: template_name = parts[0]
...: pjax_template_name = parts[1] if len(parts) == 2 else default
...: return template_name, pjax_template_name
...:

In [2]: def y(a, t='ajax.html'):
...: t1, t2 = a.split(',', 1)
...: return t1, t2 or t
...:

In [3]: %timeit x('base.html,base2.html')
1000000 loops, best of 3: 704 ns per loop

In [4]: %timeit y('base.html,base2.html')
1000000 loops, best of 3: 381 ns per loop

In [5]: %timeit x('base.html,base2.html')
1000000 loops, best of 3: 695 ns per loop

In [6]: %timeit y('base.html,base2.html')
1000000 loops, best of 3: 379 ns per loop