youtube / spitfire

A high-performance Python template language
BSD 3-Clause "New" or "Revised" License
403 stars 59 forks source link

Python 3 support #75

Open eirnym opened 5 years ago

eirnym commented 5 years ago

Please, provide support for python 3

septatrix commented 3 years ago

I just had some spare time and decided to run the benchmark with python 3:

Python 3.8.6 (default, Jan 27 2021, 15:42:20) 
[GCC 10.2.0]
Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
Package       Version
------------- -----------
asgiref       3.3.1
Cheetah3      3.2.6.post1
Django        3.1.7
Jinja2        2.11.3
Mako          1.1.4
MarkupSafe    1.1.1
pip           20.1.1
pkg-resources 0.0.0
pytz          2021.1
setuptools    44.0.0
spitfire      0.0.1
sqlparse      0.4.1
Running benchmarks 1000 times each...

The following template engines are not installed and will be skipped in the benchmark: ['spitfire']
Cheetah template                               13.84 ms
Django template                                58.68 ms
Django template autoescaped                    58.95 ms
Jinja2 template                                 3.15 ms
Jinja2 template autoescaped                     5.92 ms
Mako template                                   2.48 ms
Mako template autoescaped                       5.45 ms
Python string template                         14.27 ms
Python StringIO buffer                          2.48 ms
Python list concatenation                       2.36 ms

Jinja and Mako come close to the performance of spitfire in python 2. It would be interesting to see how spitfire performs in python 3 or if we are just better of just using e.g. Jinja with PyPy or similar which is also known to improve performance by a significant amount.

re-masashi commented 1 year ago

Maybe too late, but I think that 2to3 will be a temporary solution if one badly needs it.

re-masashi commented 1 year ago

You can now get the Python 3 supported version on my fork.

re-masashi commented 10 months ago

@trimbo Can I take over this issue? I have documented the code and the template syntax and prepared a template environment (a class which loads templates). This makes Spitfire more accessible. It's also available as a PyPi Package

TL;DR: I would like to oversee this issue. Thanks in advance.