473,769 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is a "real" C-Python possible?

I understand that the standard Python distribution is considered
the C-Python. Howerver, the current C-Python is really a combination
of C and Python implementation. There are about 2000 Python files
included in the Windows version of Python distribution. I'm not sure
how much of the C-Python is implemented in C but I think the more
modules implemented in C, the better performance and lower memory
footprint it will get.

I wonder if it's possible to have a Python that's completely (or at
least for the most part) implemented in C, just like PHP - I think
this is where PHP gets its performance advantage. Or maybe I'm wrong
because the core modules that matter are already in C and those Python
files are really a think wrapper. Anyhow, if would be ideal if Python
has performance similar to Java, with both being interpreted languages.

Jack
Dec 9 '07
71 3351
sturlamolden <st**********@y ahoo.nowrites:
On 10 Des, 23:49, a...@pythoncraf t.com (Aahz) wrote:
>"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare (often misattributed to Knuth, who was himself quoting
Hoare)

Oh, I was Hoare? Thanks. Anyway, it doesn't change the argument that
optimizing in wrong places is a waste of effort.
Although sometimes people seem to think that it goes "optimisati on is
the root...". The "premature" bit is significant.
Dec 11 '07 #31
On Dec 11, 2007 1:25 PM, John Nagle <na***@animats. comwrote:
sturlamolden wrote:
On 10 Des, 23:49, a...@pythoncraf t.com (Aahz) wrote:
"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare (often misattributed to Knuth, who was himself quoting
Hoare)

We're ten years into Python, and it's still a naive interpreter.
This is an absurd misrepresentati on of the state of the Python VM.
It's time for a serious optimizing compiler. Shed Skin is going
in the right direction. But for some reason, people seem to dislike the
Shed Skin effort. Its author writes "Am I the only one seeing the potential
of an implicitly statically typed Python-likea-lnguage that runs at
practically the same speed as C++?"

"For a set of 27 non-trivial test programs (at about 7,000 lines in total;
... measurements show a typical speedup of 2-40 times over Psyco, about 10 on
average, and 2-220 times over CPython, about 35 on average." So that's
what's possible.
.... with roughly a hundredth of the python standard library, and a
bunch of standard python features not even possible. I like
generators, thanks.

If shedskin can actually match Pythons feature set and provide the
performance it aspires to, thats great, and I may even start using it
then. But in the meantime, hardly anything I write is CPU bound and
when it is I can easily optimize using other mechanisms. Shedskin
doesn't give me anything that's worth my time to improve on it, or the
restrictions it places on my code. I think JIT is the future of
optimization anyway.
I'm surprised that Google management isn't pushing Guido towards
doing something about the performance problem.
Assuming your conclusion (ie, that there's a performance problem to do
something about) doesn't prove your case.
Dec 11 '07 #32
sturlamolden <st**********@y ahoo.nowrites:
On 10 Des, 23:54, Bruno Desthuilliers
<bdesth.quelque ch...@free.quel quepart.frwrote :
>Or a lack of time and money. Lisp is one of the older programming
languages around, and at a time had BigBucks(tm) invested on it to try
and make it practically usable.

Yes. But strangely enough, the two Lisp implementations that really
kick ass are both free and not particularly old.
Not two, but one -- SBL is simply a fork of CMU CL. As for their age,
the CMU CL states that it has been "continuall y developed since the
early 1980s".
Dec 11 '07 #33
On Tue, 11 Dec 2007 11:25:32 -0800, John Nagle wrote:
sturlamolden wrote:
>On 10 Des, 23:49, a...@pythoncraf t.com (Aahz) wrote:
>>"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare (often misattributed to Knuth, who was himself quoting
Hoare)

We're ten years into Python, and it's still a naive interpreter.
It's time for a serious optimizing compiler. Shed Skin is going in the
right direction. But for some reason, people seem to dislike the Shed
Skin effort. Its author writes "Am I the only one seeing the potential
of an implicitly statically typed Python-like-language that runs at
practically the same speed as C++?"

"For a set of 27 non-trivial test programs (at about 7,000 lines in
total;
... measurements show a typical speedup of 2-40 times over Psyco, about
10 on average, and 2-220 times over CPython, about 35 on average." So
that's what's possible.

I'm surprised that Google management isn't pushing Guido towards
doing something about the performance problem.
Maybe because it isn't as much a problem as people with C envy assume it
must be? (Disclaimer: I'm not suggesting that John is one of those
people.)

Not that I'd object to anyone else doing the work to speed up Python, but
for the things I use Python for, I've never felt the need to say "Gosh
darn it, my script took twelve milliseconds to run, that's just too
slow!!!". Maybe Google are in the same boat?

Actually, in Google's case, I guess their bottleneck is not Python, but
trying to push around gigabytes of data. That will be slow no matter what
language you write in.

--
Steven.
Dec 11 '07 #34
John Nagle schrieb:
sturlamolden wrote:
>On 10 Des, 23:49, a...@pythoncraf t.com (Aahz) wrote:
>>"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare (often misattributed to Knuth, who was himself quoting
Hoare)

We're ten years into Python, and it's still a naive interpreter.
It's time for a serious optimizing compiler. Shed Skin is going
in the right direction. But for some reason, people seem to dislike the
Shed Skin effort. Its author writes "Am I the only one seeing the potential
of an implicitly statically typed Python-like-language that runs at
practically the same speed as C++?"

"For a set of 27 non-trivial test programs (at about 7,000 lines in
total; ... measurements show a typical speedup of 2-40 times over Psyco,
about 10 on average, and 2-220 times over CPython, about 35 on
average." So that's
what's possible.
No, it's not. Shedskin is interesting, but just a small subset of Python
- and without completeness, performance is useless.

The PyPy approach is much more interesting - first create a
full-featured Python itself, then create optimizing backends for it,
also for just a language subset - RPython.

And if possible - which it is only in a very limited set of cases for
not type-annotated code - identify parts that conform to RPython's
constraints, and compile that JITly.

Diez
Dec 11 '07 #35
John Nagle a écrit :
sturlamolden wrote:
>On 10 Des, 23:49, a...@pythoncraf t.com (Aahz) wrote:
>>"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare (often misattributed to Knuth, who was himself quoting
Hoare)


We're ten years into Python, and it's still a naive interpreter.
It's time for a serious optimizing compiler.
Care to provide a less "naive" one ?

(snip usual rant)
I'm surprised that Google management isn't pushing Guido towards
doing something about the performance problem.
Could it be possible they don't see Python's perfs as a "problem" ?

Ok, I don't mean there's no room for improvement here. If you feel like
addressing the problem, you're welcome - in case you didn't notice,
Python is free software.
Dec 11 '07 #36
On 11 Des, 20:25, John Nagle <na...@animats. comwrote:
Shed Skin effort. Its author writes "Am I the only one seeing the potential
of an implicitly statically typed Python-like-language that runs at
practically the same speed as C++?"
Don't forget about Pyrex and PyPy's RPython.

By the way, we don't need a hotspot JIT compiler. Lisp has a compiler
invoked by the programmer. We could include optional static typing in
Python, and have an optional static optimizing native compiler for
selected portions of code. That would be easier to implement in the
short run, with JIT-capabilities added later. Pyrex, ShedSkin or
RPython are all good starting points.



Dec 11 '07 #37
sturlamolden a écrit :
-snip)
We could include optional static typing in
Python,
Please wait - going to get my gun...
Dec 12 '07 #38
On Dec 12, 2:18 am, Kay Schluehr <kay.schlu...@g mx.netwrote:
On Dec 12, 7:34 am, sturlamolden <sturlamol...@y ahoo.nowrote:
I am not sure why a new type annotation syntax was needed Python 3:

Because people care about a feature when there is @syntax.
Good point; the inverse is not true though: time and time again people
cared about some syntax for properties without any change so far. The
result is a handful of different ways to spell out properties; python
2.6 will add yet another variation (http://mail.python.org/pipermail/
python-dev/2007-October/075057.html).

George
Dec 12 '07 #39
On Dec 12, 9:04 am, George Sakkis <george.sak...@ gmail.comwrote:
On Dec 12, 2:18 am, Kay Schluehr <kay.schlu...@g mx.netwrote:
On Dec 12, 7:34 am, sturlamolden <sturlamol...@y ahoo.nowrote:
I am not sure why a new type annotation syntax was needed Python 3:
Because people care about a feature when there is @syntax.

Good point; the inverse is not true though: time and time again people
cared about some syntax for properties without any change so far. The
result is a handful of different ways to spell out properties; python
2.6 will add yet another variation (http://mail.python.org/pipermail/
python-dev/2007-October/075057.html).

George
Yes, I'm aware. Curiously, whenever property syntax is discussed the
discussion loses track and is dragged away by needless side
discussions. Just look at Stephen Bethards withdrawn PEP 359 [1] in
which he finally muses about replacing the class statement by the make
statement. So the PEP ended in "abstract nonsense" instead of
clarifying the point.

[1] http://www.python.org/dev/peps/pep-0359/

I vaguely remember a discussion a few years ago, where someone made
the quite reasonable suggestion of introducing some kind of
thunk_statement :

class A(object):
foo = property:
def fget(self):
return self._foo
def fset(self, value):
self._foo = value

which was translated as follows:

class A(object):
def thunk():
def fget(self):
return self._foo
def fset(self, value):
self._foo = value
return vars()
foo = propery(**thunk ())
del thunk

Now people started to consider using the compound statement within
expressions as well because the equal sign is used within method
signatures and call syntax. This lead to a general discussion about
the expr/statement distinction in Python, about multiline lambdas and
functional style programming. These association graphs are almost
predictable.

Dec 12 '07 #40

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

Similar topics

2
1812
by: Ira Baxter | last post by:
My understanding is that Zend are the folks behind the one and only PHP implementation. Now that PHP5 is released, I'm quite interested in using it. However, the documentation avialable at PHP.NET suggests that it isn't by Zend. What reason is there to believe it is complete and accurate in any sense? (There's lot of user clarifications which show that it isn't complete). In particular, the section of PHP5 has parts that are...
7
14842
by: Aryeh M. Friedman | last post by:
If have something like the following declartion: enum foo {One,Two,....,Ten}; How do I determine how many elements (enumerations)... in this case it is obviously 10 but I don't want to hard code that fact --Aryeh
11
2986
by: Nobody | last post by:
Heres the deal... I have an application where I have a list (as in a Windows list control, but thats not important) displayed to the user. I sort this list based on the list controls sort function (again, its not important that its Windows) which ends up calling a compare function in my code: int CompareFunc(char* str1, char* str2) { } this function returns -1, 0 or 1 which gets passed on to the internal quick
4
3135
by: Silas | last post by:
Hi, I use view to join difference table together for some function. However, when the "real" table fields changed (e.g. add/delete/change field). The view table still use the "old fields". Therefore everytimes when I change the real table, I also needed open the view table and save it by SQL enterprise manager manually for update the view table field.
0
1083
by: Simon Verona | last post by:
I have some Windows Forms software that I'm developing that uses a remote server (called using remoting) to provide the business rules and dataaccess. For development purposes the client and server portions are both running on my PC. I was wondering if there was some way that for "real world" performance, I could somehow "throttle" the tcp/ip stack so that calls to localhost had some lag to represent the latency/bandwidth of a real...
0
393
by: David Garamond | last post by:
I want to know how functional indexes are used "in the real world". Here are the common uses: * non-unique index on the first parts of a longish text field (SUBSTRING(field)) to save disk space, while still allowing faster searches than a sequential scan. * indexing on LOWER(field)/UPPER(field) to allow case-insensitive searches or case-insensitive unique constraint.
5
39934
by: playagain | last post by:
Please help me to build a list of examples of stack and queue in real life situation... Conditions: The object concerned must only one object. And the object must be tangible. Example: Queue (FIFO): The bullet in a machine gun..(you cannot fire 2 bullets at the same time) Stack (LIFO): The tennis balls in their container.. (you cannot remove 2 balls at the same time)
1
3132
by: Tyno Gendo | last post by:
Hi everyone I need to move on a step in my PHP... I know what classes are, both in PHP4 and 5 and I'm aware of "patterns" existing, but what I'm looking for are some real world projects eg. Open Source that people consider to use classes and patterns correctly. I lack a senior person to lead me in this so I feel I'm losing out on only using bare PHP class features and not really knowing how to design
1
1598
by: jamesicus | last post by:
.......... just for curiosity? "real" XHTML served as content (MIME) type application/xhtml+xml will display in MSIE 6.0 release 2900 and 7.0 but they will not render xml content. However, MSIE 6.0 release 2800 and earlier displays a download screen -- selecting OPEN presents a plain, text only, rendered page -- sans style sheet. Here is an XHTML page served as content (MIME) type application/xhtml+xml for testing by those interested. ...
0
174
by: Ignacio Machin ( .NET/ C# MVP ) | last post by:
The difference between compile & runtime. CreateInstance works at runtime, you can pass ANY string to it (even an incorrect one like "123123123123") and it will compile Only at runtime you will get the error. And honestly, you HAVE to know something about your Class. otherwise, how do you know which method to call?
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10215
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9996
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3964
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.