Re: why did these companies choose Tcl over Python

2007-11-06 Thread VernM
On Oct 30, 1:25 pm, chewie54 <[EMAIL PROTECTED]> wrote:
> Hello,
>
> As an electronics engineer I use some very expensive EDA CAD tool
> programs that are scriptable using Tcl.  I was wondering why these
> companies have choose to use Tcl instead of Python.   Some of these
> are:
>
>Mentor Graphics ModelTech VHDL and Verilog simulator
>Synopsys  Design Compiler and Primetime Static Timing Analyzer
>Actel FPGA tools.
>
> Tcl seems to very popular in my business as the scripting language of
> choice.
>
> I'm in the process of deciding to use Tcl or Python for a CAD tool
> program that I have been working on.Most of the core of the
> program,  the database,   will be done is C as an extension to either
> Tcl or Python,   but I intend to use Tk or wxPthon for the GUI.   I do
> need publishing quality outputs from drawings done on a graphics
> device that are scaled to standard printer paper sizes.
>
> I would prefer to use Python but can't deny how popular Tcl is,  as
> mentioned above,  so my question is why wasn't Python selected by
> these companies as the choice of scripting languages for their
> product?
>
> Are there any obvious advantages like:
>
> performance,
> memory footprint,
> better cross-platform support,
> ease of use,
>
> Thanks in advance for your thoughts about this.

I'm an electrical engineer too, and have lamented the same lack of
Python scripting for tools like the ModelTech VHDL simulator. I think
the original choice had to do with with the ease of embedding TCL into
applications written in C, and the use of TCL in university EE
departments. I would rather die than try to write anything approaching
a complete application in TCL. Other braver souls have actually done
it, but I am sure they are masochists.

About a year ago I discovered an interesting project that embedded
Python in TCL (!).  it's called TCLPython. I have tried this out with
ModelSim 6.2, and it actually works! I have written a few Python
scripts that drive a signal in a VHDL simulation.

Here is a link: 
http://www.ellogon.org/petasis/index.php?option=com_content&task=view&id=27&Itemid=43

Best regards, Vern Muhr

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Written in C?

2008-07-28 Thread VernM
On Jul 20, 3:50 pm, [EMAIL PROTECTED] wrote:
> I'm just learning about Python now and it sounds interesting. But I
> just read (on the Wiki page) that mainstream Python was written in C.
> That's what I was searching for: Python was written in what other
> language?
>
> See, my concern was something like: OK, if Python is so hot, then,
> hopefully someone is writing it in assembly language for each MPU chip
> out there. Otherwise, if, say, they've written it in C#, then it looks
> like the REAL, generally useful language to learn is C# and Python is
> akin to Visual Basic or something: a specialty languagewhereas
> REAL WORLD programmers who want to be generally useful go and learn
> C#.
>
> So I was suspecting the Python compiler or interpreter is written in a
> REAL language like C#. So, Wiki says it's written in C! It's almost as
> if it were an intentional trick...write your own, new language in an
> OLD, real world language that is passe. Compile it into executable
> modules of course, so it is a real, working compiler, alright. But the
> SOURCE is some old, high level language which no one wants to use
> anymore! So now you've got a hot new language package and no one can
> say "well, it is written in, the SOURCE code is written in, a REAL
> language." No, it's not! The source is some outdated language and
> compiler and no one is going to prefer learning THAT to learning your
> hot new language!
>
> I'm not dissing Python, here. Just noting that, if it is written in C,
> that throws a curve at me in trying to balance the value of learning
> Python vs. some other major language.

Thank you giveitawhril2...!!

I haven't had so much fun reading a thead in years. Hilarious
--
http://mail.python.org/mailman/listinfo/python-list


cytpes **int

2008-04-28 Thread VernM
I am using ctypes to wrap a set of functions in a DLL. It has been
going very well, and I am very impressed with ctypes. I want to call a
c function with a signature of: void func(int **cube), where the array
if ints in cube is modified by func. I want to setup cube with int
values, and access them after the call to func. I unerstand how to
setup the ctypes array, but how do I pass **cube to the function, and
how do I access the results?
--
http://mail.python.org/mailman/listinfo/python-list


Re: cytpes **int

2008-04-29 Thread VernM
On Apr 28, 11:57 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Gabriel Genellina schrieb:
>
>
>
>
>
> > [snip repetition]
>
> > That's true for "a pointer to a pointer to int", and it's valid if the
> > functions references **b or b[0][0] - but in this case int** probably
> > means "[pointer to] an array of arrays of int" and presumibly the
> > function will try to access b[3][2] (or whatever indices are in range).
> > The duality pointer/array in C is dangerous when defining interfases -
> > you have to know how the value is intended to be accessed.
> > (I assume the function modifies the integer values, but not the pointers
> > themselves)
>
> > # build an array of 10x10 ints
> > Arr10int = c_int * 10
> > Pint = POINTER(c_int)
> > PPint = POINTER(Pint)
> > Arr10pint = Pint * 10
> > a = Arr10pint()
> > for i in range(10):
> >     a[i] = Arr10int()
> > ... initialize the array ...
> > ... load the function ...
> > # call the function
> > somefunction.argtypes = (PPint,)
> > somefunction.restype = None
> > somefunction(a)
>
> Yup, you are right - I somehow missed the access description and thought
> of the pointer-to-a-pointer as out-parameter-spec.
>
> Diez- Hide quoted text -
>
> - Show quoted text -


To provide a little more detail: currently, a DLL function uses malloc
to create a pointer to a block of memory where the ints are stored
This pointer is returned to python. Then a pointer to this pointer is
passed to another C function which manipulates the ints. When that C
function returns, python needs to access the int values. I am now able
to get this to work with this grossly ugly code.

# Setup a place to store the *int pointer
pt = (ctypes.c_int * 1)
cube = pt()
cube[0] = dll.AllocCube() # Get the pointer to the ints

# Call the function that manipulates the ints
dll.FirstPrime(ctypes.byref(cube))

# Create a python list of the ints
result = [ctypes.c_int.from_address(cube[0]+i*4).value for i in
range(5)]

I appreciate the suggestions so far. I know there must be a cleaner
way to express this. I would prefer the array of ints to be built by
cytpes, rather than by a C function in the DLL.




--
http://mail.python.org/mailman/listinfo/python-list