![]() |
compiling python scripts
is there a way to compile python scripts in maemo?
|
Re: compiling python scripts
Um... You don't 'compile' a python script??
Python is an interpereted language.. not a compiled language.. it simply reads commands form a python script line by line and executes them.. just like Perl, Ruby, Bash, Visual Basic, Batch... Maybe I'm missing something? If you install the python tools in maemo, most python scripts should run fine - assuming you have the dependencies required for them.. |
Re: compiling python scripts
Not sure if this is right...
Code:
$ sudo gainroot |
Re: compiling python scripts
no, i meant if i ever wanted to have a distribution and no-one to see the source.
|
Re: compiling python scripts
Quote:
You can also tell Python to produce "optimized" and documentation-less byte code with the -OO switch, e.g. Code:
python -OO myapp.py |
Re: compiling python scripts
Btw, Canola2 is mostly closed-source and just ships the byte code, if you need an example (of how to annoy people by not releasing the source code...)
|
Re: compiling python scripts
Quote:
Generally, you really have little or no reason to ever compile Perl or Python code.. but you are incorrect. http://www.faqs.org/docs/perl5int/compiler.html More specifically, for Python: http://docs.python.org/lib/compiler.html This seems interesting, but considering it's resources and architecture requirements, it wouldn't work in this case at all: http://psyco.sourceforge.net/introduction.html But I digress and return to the original point--you really shouldn't try to COMPILE Python code. There's little to no advantage at all and there's often a disadvantage to it. Is there a specific purpose you had in mind that you think requires compiled code to run? |
Re: compiling python scripts
Quote:
|
Re: compiling python scripts
So those that say I am incorrect (I hadn't seen the bytecode):
Can you run/execute Python bytecode without python installed? "Compiled" languages - IE C++ - do no required the end user to actually have C++ installed on the machine to run their application.. that is my determination of a 'compiled' language... I knew of perl modules that "scrambled" the perl code.. like ACME something or other.. but straight from perl's page: Quote:
Quote:
That is also no different than trying to "encrypt" a file.. a bytecode translator could likely (I would think) be relatively easy written to change from bytecode to english again. If the python's bytecode could be distributed and used so long as the appropriate libraries were on the destination machine without needing python.. then I'd see it being more of a hybrid between an interpereted and compiled language. But then I'm not a software developer all day.. I merely do coding as a side-hobby. I also didn't know about Canola.. it seems silly to me why someone would use a scripting language to write a closed source application.. that doesn't make much sense in my mind. |
Re: compiling python scripts
Maybe you should stop thinking about Python as a "scripting language" just because it's being interpreted. It actually sucks at being a good scripting language. Common scripting languages such as Perl or shell code do that job much better, in my opinion.
Python is a dynamically typed object-oriented interpreted language, so I would rather compare it more with smalltalk or Java rather than with common scripting languages. Btw, Java programs also need java to be run on a machine. The same goes with .net. If you really need to compile Python code into an executable which runs without python, you should take a look at "freeze", IIRC. |
Re: compiling python scripts
yes i have found freeze too.
as you can tell from my name, i am a programmer (borland delphi is my favorite). im just interested in learning python, never did it before.. so im just asking these things for future reference, and to see if its worth my time with python, or learn C++ (ive done c++ before, its just been years and on a different platform) there isnt any particular application in mind. |
Re: compiling python scripts
My reading tells me that Python uses a virtual machine like Java does.. and it DOES compile its own tokenized instructions the way Java (and Assembly for that matter). So you CAN 'compile' it and if you just have the Python's virtual machine to run the tokenized code, you don't need the entire Python language installed.
|
| All times are GMT. The time now is 22:02. |
vBulletin® Version 3.8.8