Python newbie

Aahz Maruch aahz at netcom.com
Sat Dec 25 23:40:59 EST 1999


In article <002601bf4f42$58e98cc0$49294b0c at amd>,
John Ratcliff <jratcliff at worldnet.att.net> wrote:
>
>Is it easy to build a version of the source that contains *only* the byte
>code interpreter, and not the run time parser and compiler?  Much of the
>Python stuff seems geared towards the interactive command line interface,
>which is nice if that's what you need, but I want to use the standard model
>of compile source to byte code, and then run only that byte code in my
>virtual machine.

While it's possible to set things up so that you only use the .pyc
files, you can't remove the parser from Python.  At best, you can only
only remove standard Python modules that you don't need (e.g. httplib if
you're not doing HTTP connections).

>Is Python virtually linked?  How does it resolve links between various
>python object modules?  At run time?

Essentially, though "link" is a misnomer for what happens in Python.
You generally have to explicitly import Python modules/packages in each
module that uses them (which makes up for a lot of the problem with lack
of static typing, IMO).

>When you create a variable in Python how is it typed?  Is it a float, an
>int, etc?  It appears to be dynamically typed, which is syntacticaly simple
>for the novice I suppose, but I am anal enough that I do like strong typing.

Might happen for Python 2.0 (likely to appear some time in 2001 or
2002), but not earlier than that.  Yes, it's pure dynamic typing -- you
can't even predeclare variables.

>More to the point, while I don't plan to put my ultra-high performance code
>in Python, I can't afford for it to be outrageously slow either.  What are
>the performance characteristics of the Python VM?

Well, it uses ref-counting, so you're guaranteed that there's no garbage
collection.  OTOH, if you make a mistake you can leak memory.  Other
than that, it's hard to make generalizations about Python performance --
one of the truisms of Pythonistas is that programming is so much easier
in Python that you get the opportunity to try several algorithms to see
what gives you the best performance.  As a programmer with your
experience knows, algorithmic improvements can give you
order-of-magnitude increases in performance.  Then, if Python still
isn't fast enough, it's pretty easy to hook Python to straight C code.

>When I used the Python GUI interface there was no option on the menu to just
>'compile' a piece of python source.  When I issued the command line option
>to compile a piece of source i.e. "compile foo" where 'foo' represents a
>Python source file on disk, it gives me an error message.

Yup.  Python really is an interpreted language; the fact that it
"compiles" to byte-code is an interesting optimization that is
irrelevant to actual language functioning.  (This comment isn't
completely true, but you should treat it as if it were true.)

Side note: there really isn't a Python GUI interface.  It's an IDE
written in Python (and Tk -- see the Tcl programming language for more
info) that provides no facilities other than what the langauge itself
does.
--
                      --- Aahz (@netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

Eighth Virtual Anniversary -- 6 days and counting!



More information about the Python-list mailing list