Python Written in C?

T

Tim Roberts

Larry Bates said:
I just learned something I did not know. I was under the impression that they
translated directly to machine code without ever actually generating Assembler
text files.

Some do, some don't. It's an implementation chioce. gcc generates a text
file and pipes it to gas. The __asm__ directive just adds strings to the
assembler file.

Visual C++ generates machine language. The compiler has to include an
assembler for inline assembly.
 
M

mk

Marc said:
An operation that most people avoid because of the penalty of "shifting
down" all elements after the deleted one. Pythonistas tend to build new
lists without unwanted elements instead.

Which is exactly what I have done with my big lxml.etree, from which I
needed to delete some elements: constructed a new tree only with
elements I wanted. Sure, that works.

There _is_ a minor side effect: nearly doubling memory usage while the
operation lasts. 99% of the time it's not a problem, sure.
> I can't even remember when I
deleted something from a list in the past.

Still, doesn't that strike you as.. workaround?

I half-got used to it, but it would still be nice not to (practically)
have to use it.

Enough whining. Gonna eat my quiche and do my Python. :)
 
M

mk

Actually, all of the compilers I'm familiar with (gcc and a
handful of cross compilers for various microprocessors)
translate from high-level languages (e.g. C, C++) into
assembly, which is then assembled into relocatable object
files, which are then linked/loaded to produce machine
language.

Doesn't g++ translate C++ into C and then compile C?

Last I heard, most C++ compilers were doing that.
 
M

Marc 'BlackJack' Rintsch

Still, doesn't that strike you as.. workaround?

No, I find it actually safer; I don't have to care where modifications of
the list might be seen elsewhere in the program.

Ciao,
Marc 'BlackJack' Rintsch
 
C

castironpi

No, I find it actually safer; I don't have to care where modifications of
the list might be seen elsewhere in the program.

Ciao,
        Marc 'BlackJack' Rintsch

a[:]= newlist

and

a= newlist

have two completely different effects, and one is just as safe as
'del'. Besides, del isn't safe to be seen elsewhere in the program in
other threads, if they aren't locking the GIL.
 
M

Marc 'BlackJack' Rintsch

No, I find it actually safer; I don't have to care where modifications of
the list might be seen elsewhere in the program.

Ciao,
        Marc 'BlackJack' Rintsch

a[:]= newlist

and

a= newlist

have two completely different effects, and one is just as safe as
'del'. Besides, del isn't safe to be seen elsewhere in the program in
other threads, if they aren't locking the GIL.

As usual you are talking nonsense…

Ciao,
Marc 'BlackJack' Rintsch
 
V

VernM

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 language....whereas
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!!!!
 
T

Tim Rowe

2008/7/21 Krishnakant Mane said:
First off all c# is absolute rubbish waist of time.

What a pity others are joining in this pointless language flame-war.

Look, I recently had to write a script for manipulating some data; I
struggled to organise it in Python and in C++, but when I tried C#
everything fell naturally into place and I had it done in next to no
time. Other times it has been Python or C++ that has been the most
natural way to express what I'm trying to do. Just because /you/
don't like C# doesn't mean it's rubbish or a waste of time; personally
I loathe Perl, but I respect the fact that a lot of programmers can
get good results very quickly in it.

I reckon that the programmer who only knows one language is like a
carpenter trying to make a cabinet with just a chisel. Ok for making
the joints (although a hammer would have been handy to hit it with),
not /really/ as good as a plane for getting large areas smooth, and
the blade keeps jumping out when you try to use it as a screwdriver...

The one-language programmer isn't really in a position to choose the
right tool for the job, because they only have one tool. Anybody who
says that a language in real use is a waste of time is denying the
reality of those who find it an effective tool. Similarly, anybody who
says that a language -- any language -- is right for all jobs plainly
doesn't understand that language design involves a lot of compromises,
and that the compromises that are appropriate choices for one task are
inappropriate for another. Python is a great tool. So is C#. You /can/
do the same job with either, but the smart move is to choose the one
that is best adapted to the task in hand.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,246
Latest member
softprodigy

Latest Threads

Top