how much does Python model my Compsci course?
greg at cosc.canterbury.ac.nz
Wed Jun 6 01:08:52 EDT 2001
Roy Katz wrote:
> non-deterministic finite automata, DFA's,
> context-sensitive grammars, grammar productions, param
> passing, function implementation, arrays.
> I'm wondering what amount of this material is applicable to Python
In the C implementation of Python, the lexical analyser
consists of what amounts to a hand-coded DFA. The syntax
is specified by a formal context-free LL(1) grammar from
which a set of parser tables is automatically generated.
The tables are used by what seems to be a form of
> Have any of you heard of a 'dope vector'? What is Python's
> internal equivalent?
As far as I remember, this refers to the technique of
implementing a 2D array using a 1D array of pointers
to 1D arrays.
There isn't really any "internal equivalent" in Python,
because it doesn't have a built-in multidimensional
array type. The NumPy extension provides multidimensional
arrays, but I don't know what sort of internal representation
it uses. At a guess, I'd say it probably doesn't use dope
vectors, but just keeps all the array elements in one
> How about a 'central environment table' (as opposed
> to 'activation records')?
I'm not sure what you mean by a 'central environment table',
but Python certainly has 'activation records'. They're
called stack frames, and they are dynamically-allocated
Python objects -- you can get hold of them and play around
with them in your Python program if you want. (This is
how the traceback is generated that you get when an
uncaught exception occurs, for example.)
> Which leads me to wonder if what I'm being taught in class is dated.
Not dated; it's just that some of it really only applies
to statically-typed, compiled-to-native-code kinds of languages
such as Pascal and C. Python is a dynamic language more
in the style of Lisp or Smalltalk. The implementation
issues are somewhat different for these kinds of languages,
and thus the techniques and terminology are different too.
But not necessarily "newer" - dynamic languages have been
around almost as long as static ones!
Greg Ewing, Computer Science Dept, University of Canterbury,
Christchurch, New Zealand
To get my email address, please visit my web page:
More information about the Python-list