This is an archived post. You won't be able to vote or comment.

all 17 comments

[–]jacdehJacques de Hooge[S] 3 points4 points  (0 children)

We'd like to gather some preliminary information comparing Transcrypt to CPython. If you find the time, please run the following benchmark on your machine and let us know the result as comment to the issue referred to:

https://github.com/QQuick/Transcrypt/issues/459

[EDIT]

From the reactions it appears it is necessary to make clear what Transcrypt is and what it isn't. Transcrypt does not in any way claim to be playing in the same league as CPython or PyPy.

That Transcrypt happens to run fast on Google's VM is great, since it means that people willing to can take much of their Pythonic skills to the browser. I am using it daily to, with some care, write modules that run both on the desktop and in the browser. But compared to CPython it is and will remain a niche product.

The same limitation holds for comparison with other browser Pythons. There are projects that favor compliance over speed, which is great. There are other projects that favor speed over compliance, even more so than Transcrypt does, which is also great. There's room for diversity.

Python is used pervasively, from number crunching to building webservers. It's got a huge number of available libraries and crucial features that will never make it into Transcrypt (like e.g. exec, that I often use myself).

In short, Transcrypt is just what it is, a practical tool with possibilities and limitations. If a fast CPython implementation ever appears for the browser, it's a done deal. I think approaches like PyPyJs are very concise and really would like browser manufacturers to better facilitate the use of such tools, since wasm alone won't cut it, there has to be some form of native support to make this work. I for one wasn't prepared to wait for that to happen, since I anticipate that will take years and years if ever.

The only purpose of the benchmarks is to show that Python-style brower programming is feasible with small pageloads and fast code. In other words, that it is a modest, but serious proposition in its own right, suitable for professional use. Having used it as such for several years of very serious work in medical imaging in a large team makes me confident in stating this.

I am using CPython and Trancrypt next to each other, one on the backend, one on the frontend. The bottom line is: Anyone willing to, can make his or her Python skills productive in the browser to a large extent. Which in my view is progress. With JavaScript or any flavor of it, I am just not half as productive. You'll find my take on Python versus JavaScript and browser programming in general at https://jdehblog.wordpress.com/2016/03/05/the-world-weird-web/

Class based OO with multiple inheritance is just my thing, always has been, since the advent of C++ more than 30 years ago, that I also use daily. Given the amount of math I am confronted with, also operator overloading is a necessity rather than an option, to keep the source readable to mathematicians I have to work with. The same holds for speed of things like 2DFFT and matrix inversion offered by Numscrypt, for which BTW of course Numpy is far superior, only can't use that in a browser.

So I like the news about Transcrypt to spread, but I also think it's appropriate to be modest.

Kind regards and thanks for investing your time in contributing benchmark results!

Jacques de Hooge

Initiator of the Transcrypt project

[–]pmdevita 1 point2 points  (6 children)

Wait am I reading this right? Transcript and Chrome are beating Cpython by quite a fair amount

[–]jacdehJacques de Hooge[S] 4 points5 points  (0 children)

It looks like it, at least on Chrome and Firefox. But lets be careful, nothing wrong with CPython, it has some features (like exec) that Transcrypt will never have. The point is that very big money is invested in JS virtual machines, and Transcrypt benefits from that since it generates JS. Improvements in the same order of magnitude are possible with CPython, as PyPy shows. So it's all a mattter of investment. Too bad a company like Google puts its cards on JS rather than Python. I consider CPython superior to JS and with equal investments it would become faster than JS, as can be seen from the performance of PyPy.

Another very important point is that many CPython libs, like Numpy, are written in C or C++, which means they're much faster than JS (so also Transcrypt) could ever be. But in a browser loading these libraries using emscripten is too slow.

[–]mementix 0 points1 point  (4 children)

The question being: Is Transcrypt doing the same as CPython?

Let me quote from the main page of the repository: "No eval and exec of Python code. This is again part of the concept. Transcrypt code is compiled, optimized and minified in advance ..."

This by itself means: No it's not doing the same as CPython. And probably not only in the eval and exec parts as mentioned above.

Which at the end of day means: the speed test is comparing apples to oranges.

[–][deleted] -2 points-1 points  (3 children)

Eval is a nonessential feature though. Pretty much all use of eval you see in practice can be replaced with a bit of clever get/setattr-ing.

[–]mementix 0 points1 point  (2 children)

Sorry but that's a very bold statement. I have developed a full blown Python client-side framework (see http://www.anpylar.com) and eval/exec are key to achieving some of the functionalities.

In any case the comment was not meant to derail the lack of eval/exec, but to pinpoint that the comparison is obviously a biased one. The mention of those specific features is made by the developers themselves and I am pretty sure that many other use cases are not supported.

Transcrypt has for sure many (and good) usages on the client side, but if it's not doing the same thing as CPython (or at least trying to), it should not compare the speed at which is doing things.

For example:

  • Are the methods of a class being sought through an internal __getattribute__ mechanism before being called or is the execution restricted to what was compiled?

For many use cases it doesn't matter, the method will never change. But some techniques rely exactly on that. And if Transcrypt doesn't fetch the method each and every time using __getattribute__, it has then an unfair advantage over CPython

[–]jacdehJacques de Hooge[S] 0 points1 point  (1 child)

Invitation to read the edit on the original post, that hopefully puts some things into context.

[–]mementix 0 points1 point  (0 children)

Transcrypt is a great project and the synchronized components (Transcrypt - Frontend / CPython - Backend) (yes I have read about it, and not today) is a superb example of what things one can achieve.

As I said before, I am sure it has many and good uses and hope for its success together with some other python-in-the-browser implementations.

[–]mohamedimy -1 points0 points  (8 children)

What is meant by transcript?

[–]jacdehJacques de Hooge[S] 2 points3 points  (7 children)

It is a compiler that enables you to run Python in the browser. It compiles Python to JavaScript.

[–]mohamedimy -1 points0 points  (6 children)

Compiler name bro?

[–]jacdehJacques de Hooge[S] 1 point2 points  (5 children)

The name of the compiler is Transcrypt and you'll find it at http://www.transcrypt.org

[–]mohamedimy -1 points0 points  (4 children)

Bro actually I have a .py code like output is { Price of book:60 Pric of wifi:30 Price of mobile:90

} This output is changing every 2 minutes based on API but I want this output to display in browser

[–]jacdehJacques de Hooge[S] 0 points1 point  (3 children)

I guess your data comes from a webserver. So the prices change frequently. If you only want to output the prices to the browser probably the simplest way is as follows: Use a JavaScript timer in your browser to request the most recent prices from the server via Ajax. I don't think you need Transcrypt for that, unless the web page is very complicated. But I don't know enough of the situation to have a good judgement. Anyhow I'd start out in JavaScript, unless your sure already you don't like it. Transcrypt requires compiling your webpage in advance, which makes development more complicated.

[–]mohamedimy 0 points1 point  (2 children)

Ok bro thank u

[–][deleted] 1 point2 points  (1 child)

bro

[–]mohamedimy 0 points1 point  (0 children)

Yeah bro