473,395 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Python Written in C?

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.
Jul 20 '08
61 6880
Larry Bates <la*********@websafe.com`wrote:
>
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.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 23 '08 #51
mk
Marc 'BlackJack' Rintsch wrote:
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. :-)


Jul 23 '08 #52
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.


Jul 23 '08 #53
2008/7/23 mk <mr****@gmail.com>:
>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.
GCC translates every language into its one as a tree, which is then
translated to assembly.

Matthieu
--
French PhD student
Website : http://matthieu-brucher.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher
Jul 23 '08 #54
On 2008-07-23, mk <mr****@gmail.comwrote:
>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?
No.
Last I heard, most C++ compilers were doing that.
A decade or two ago there were some C++ front-ends that did
that, but I don't think it's common in modern C++ compilers.

--
Grant Edwards grante Yow! Oh, I get it!!
at "The BEACH goes on", huh,
visi.com SONNY??
Jul 23 '08 #55
On Wed, 23 Jul 2008 14:10:22 +0200, mk wrote:
Marc 'BlackJack' Rintsch wrote:
>I can't even remember when I deleted something from a list in the past.

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
Jul 23 '08 #56
On Jul 23, 9:11*am, Marc 'BlackJack' Rintsch <bj_...@gmx.netwrote:
On Wed, 23 Jul 2008 14:10:22 +0200, mk wrote:
Marc 'BlackJack' Rintsch wrote:
I can't even remember when I deleted something from a list in the past..
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
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.
Jul 23 '08 #57
On Wed, 23 Jul 2008 09:42:29 -0700, castironpi wrote:
On Jul 23, 9:11Â*am, Marc 'BlackJack' Rintsch <bj_...@gmx.netwrote:
>On Wed, 23 Jul 2008 14:10:22 +0200, mk wrote:
Marc 'BlackJack' Rintsch wrote:
I can't even remember when I deleted something from a list in the past.
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

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
Jul 23 '08 #58
On Jul 23, 12:10*pm, Marc 'BlackJack' Rintsch <bj_...@gmx.netwrote:
On Wed, 23 Jul 2008 09:42:29 -0700, castironpi wrote:
On Jul 23, 9:11*am, Marc 'BlackJack' Rintsch <bj_...@gmx.netwrote:
On Wed, 23 Jul 2008 14:10:22 +0200, mk wrote:
Marc 'BlackJack' Rintsch wrote:
I can't even remember when I deleted something from a list in the past.
Still, doesn't that strike you as.. workaround?
No, I find it actually safer; I don't have to care where modificationsof
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
As usual you are taking flamebait!
Jul 24 '08 #59
On Jul 20, 3:50*pm, giveitawhril2...@gmail.com 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 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!!!!
Jul 28 '08 #60
The OO overheads for C++ are almost non-existent.
http://www.informit.com/articles/art...92024&ns=15058

On Mon, Jul 21, 2008 at 2:05 PM, Dan Upton <up***@virginia.eduwrote:
On Mon, Jul 21, 2008 at 1:21 PM, Marc 'BlackJack' Rintsch
<bj****@gmx.netwrote:
>On Mon, 21 Jul 2008 18:12:54 +0200, mk wrote:
>>Seriously, though, would there be any advantage in re-implementing
Python in e.g. C++?

Not that current implementation is bad, anything but, but if you're not
careful, the fact that lists are implemented as C arrays can bite your
rear from time to time (it recently bit mine while using lxml). Suppose
C++ re-implementation used some other data structure (like linked list,
possibly with twists like having an array containing pointers to 1st
linked list elements to speed lookups up), which would be a bit slower
on average perhaps, but it would behave better re deletion?

Aside (actual reply below): at least for a sorted LL, you're basically
describing Henriksen's algorithm. They can asymptotically be faster,
based on amortized analysis, but they're somewhat more complicated to
implement.
>>
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. I can't even remember when I
deleted something from a list in the past.

Ciao,
Marc 'BlackJack' Rintsch

The other side of the equation though is the OO-overhead for C++
programs as compared to C. (A couple years ago we used an
instrumentation tool to check the instruction count for a simple hello
world program written in C (ie, main(){printf("Hello world!"); return
0;}) and Python (main(){cout<<"hello world"<<endl;return 0;}), and the
instruction count was significantly higher for C++. I expect any sort
of C++ objects you used to implement Python structures will be slower
than the equivalent in C. So even if writing it in C++ would reduce
the overhead for deleting from a list, I expect you would lose a lot
more.
--
http://mail.python.org/mailman/listinfo/python-list


--

Warren Myers
http://warrenmyers.com
Jul 29 '08 #61
2008/7/21 Krishnakant Mane <ha*******@gmail.com>:
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.

--
Tim Rowe
Aug 1 '08 #62

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David Stockwell | last post by:
Hi, Today I was in a meeting and someone mentioned they were looking for some software whereby they could run their own fax server (ie a computer with a modem, someone sends a fax, and the...
0
by: thomasasta | last post by:
Hey there is a new python written open source bit-torrent client out. Don´t mit it up with brams c++ bittorrent, in python it is bit-torrent.sf.net Don´t forget the minus - ...
4
by: Michiel Overtoom | last post by:
Giveitawhril wrote... No: Real programmers first eat a quiche and then return to their Pascal programming. C is alive and kicking. Every language has its place. Plus, there exists...
0
by: Phil Runciman | last post by:
On 20 jul, 19:50, giveitawhril2...@gmail.com wrote: ".. if Python is so hot.." Python represents progress not the ultimate goal. Thank goodness we are continuing to learn from past mistakes. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.