Python questions -> compiler and datatypes etc

Billy billy_bill_1 at yahoo.com
Wed Oct 10 06:01:30 EDT 2001


Yeah, java can do the job, but so can C++... see what
I mean? Just cause it can do it doesn't mean its
practical. Java is ok for webdev (i have done a bit)
it's just tediously slow in implementing sometimes.

Zend Encoder (www.zend.com) takes text php code and
puts it into an intermedary format not readable by
humans. each time a script is called the interpreter
calls the encoded script. This means you can
distribute your applications without letting people
see the code.

I've seen various reviews, the scientific basis of
them was rather dubious but you could definately
gather a general feeling that python was slower than
java, to a reasonable extent.

------------------------------------------------------

Compiling python is at the impossible end of the
> scale of ease of 
> implementation. There has been a lot of discussion
> about this issue on this 
> list in the past. Search for "python compiler" and
> enjoy :)

> Python compiles to bytecode. Python's runtimes
> execute compiled bytecode. 
> There are several runtimes - one of which is Java.
> The predominant one is 
> written in C. 

-------------------------------------------

I'm unclear on your explanation here. Would I be
correct in saying that there is no compiler (source
code to machine code) for python. And that this is due
to the very complex nature of implementing such a
device.

*Off topic:
I would be interested in finding out more information
on this, why can't you do it with python when people
are doing it with java? Any pointers to web resources
etc??

And you say that the python interpreter takes bytecode
and executes that. Does this mean that you can use
python to compile your source code into a format which
is not readable by humans (bytecode or whatever..
which is as reasonably reverse-engineering proof) and
distribute that bytecode (not source code) to stop
tampering and protect your commercial interests?

I did do an extensive search for information on a
python compiler... all accross the web, all i found
were a few "discontinued" sites that dated back to
June 5th 1957. I never ask questions without checking
for myself first.

I would want to use strict datatypes and generic types
to interchange speed and efficency with flexability.
Java lets you define 
int foo()
double foo() and
object foo()

very nice for building generic classes.

keyword args/ (*args thing <- can't quite understand
that one) can't do the same as say:

excuse the syntax... not familiar enough with python
yet

class foo:
#load foo from file
define foo(filename, directory)
filesystem calls etc etc...

#load foo from database
define foo(datbasename)
connect to database etc etc......

or even better
#load foo from file
define foo(FileHandler fhFile)
bla bla bla

#load foo from database
define foo(DatabaseObject database)
bla bla bla

So what your saying is that python doesn't have the
ability to switch between this?

Thanks heaps for your time,
Billy





--- Richard Jones <richard at bizarsoftware.com.au>
wrote:
> On Monday 08 October 2001 16:32,
> billy_bill_1 at yahoo.com wrote:
> > I've been using php for ages for webdev and I
> don't like it. It lacks
> > so many simple features, and I can't be bothered
> using Java to use
> > those features. IMHO java is not suited for
> specific web development.
> 
> There's a lot of server-side Java programmers who
> would disagree with that 
> statement. Python is better, but Java can do the
> job.
> 
> 
> > So I find python, I like python. Python has
> everything I need, except
> > (apparently) the ability to encode it (php: Zend
> Encoder) or
> 
> Sorry, what do you mean by "encode it"? I'm not
> familiar with "Zend Encoder".
> 
> 
> > compile
> > it into Bytecode like java.
> 
> Python compiles to bytecode. Python's runtimes
> execute compiled bytecode. 
> There are several runtimes - one of which is Java.
> The predominant one is 
> written in C. 
> 
> 
> > It seems its not nearly as fast as java.
> > (Acceptable in most cases though).
> 
> How did you measure this?
> 
> 
> 
> > Are there any products coming out involving
> compilation of python?
> > Like a 2 stage interpreter like java... that would
> be tops... speed
> > and ability to sheild source code from prying and
> tampering eyes.
> 
> Compiling python is at the impossible end of the
> scale of ease of 
> implementation. There has been a lot of discussion
> about this issue on this 
> list in the past. Search for "python compiler" and
> enjoy :)
> 
> 
> > Does python have the ability to let the programmer
> change between
> > strongly typed and loosly typed as needs be?
> 
> No, unless you venture into JPython land, where you
> could mix Java code 
> (strict, strong typing) and Python code (dynamic,
> strong typing) in the one 
> project. Why on earth you'd want to is beyond me
> though :)
> 
> 
> > python support function overloading?
> 
> Traditional overloading, which allows a function to
> have multiple signatures 
> to allow different types to be passed in has no
> relevance in a dynamically 
> typed language like Python. Witness:
> 
> Python 2.1.1 (#1, Jul 20 2001, 22:37:24) 
> [GCC 2.96 20000731 (Mandrake Linux 8.1
> 2.96-0.58mdk)] on linux-i386
> Type "copyright", "credits" or "license" for more
> information.
> >>> def foo(sequence):
> ...  for element in sequence:
> ...   print sequence.index(element), element
> ... 
> >>> foo(['a', 'list'])
> 0 a
> 1 list
> >>> foo('a string')
> 0 a
> 1  
> 2 s
> 3 t
> 4 r
> 5 i
> 6 n
> 7 g
> >>>
> 
> 
> [note: that's a cutnpaste from an inetractive
> session with the interpreter]
> 
> 
> > variable length parameter lists?
> 
> Yep, and keyword arguments too. Continuing on from
> the previous interactive 
> session, we redefine foo:
> 
> >>> def foo(*args):
> ...  print 'My args', args
> ... 
> >>> foo(1, 2, 'hello', 3, foo)
> My args (1, 2, 'hello', 3, <function foo at
> 0x8131acc>)
> >>>
> 
> Keyword args:
> 
> >>> def foo(food='spam', container='tin'):
> ...  print '%s in a %s'%(food, container)
> ... 
> >>> foo()
> spam in a tin
> >>> foo(food='eggs')
> eggs in a tin
> >>> foo('curry', 'hurry')
> curry in a hurry
> >>>
> 
> 
> I suggest spending half an hour walking through the
> Python Tutorial. For 
> added fun, type in the stuff in the tutorial into an
> interactive interpreter 
> at the same time. That's how I learnt Python.
> 
> 
>     Richard



__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com




More information about the Python-list mailing list