f



Subsets of Python implemented in Python

I don't understand why some parts of the Python language (or the Python 
standard library too) are implemented in C while some other parts are 
implemented in the Python language itself. For instance, lists and 
dictionnaries are implemented in C but sets are not.

Wouldn't be better to implement all in C (for efficiency reasons for 
example) ?
0
candide (110)
7/16/2010 11:34:48 PM
comp.lang.python 77058 articles. 6 followers. Post Follow

2 Replies
1233 Views

Similar Articles

[PageSpeed] 14

On Jul 17, 12:34=A0am, candide <cand...@free.invalid> wrote:
> I don't understand why some parts of the Python language (or the Python
> standard library too) are implemented in C while some other parts are
> implemented in the Python language itself. For instance, lists and
> dictionnaries are implemented in C but sets are not.
>
> Wouldn't be better to implement all in C (for efficiency reasons for
> example) ?

CPython's sets are implemented in C. Old versions of Python
implemented sets in the 'set' module which was written in Python but
that has been deprecated and removed. A lot of the standard library is
implemented in Python because it makes it more easily portable to non-
CPython implementations.

Chard.
0
Richard
7/16/2010 11:54:05 PM
On Sat, 17 Jul 2010 01:34:48 +0200, candide wrote:

> I don't understand why some parts of the Python language (or the Python
> standard library too) are implemented in C while some other parts are
> implemented in the Python language itself. For instance, lists and
> dictionnaries are implemented in C but sets are not.
> 
> Wouldn't be better to implement all in C (for efficiency reasons for
> example) ?

Efficiency for who? The person writing the code? The CPU?

There's currently a thread about the difficulty of finding volunteers 
willing *and able* to fix bugs in Python. If all of the Python code base 
was written in C, this would be a thousand times worse. There are many 
Python developers who can patch Python code, but not even read C code, 
let alone write it effectively.

Most of the Python standard library is written in Python because 

(1) it's easier
(2) it's fast enough
(3) it allows experimentation and rapid prototyping

E.g. the sets module was written in Python to start with, then replaced 
with a C built-in once it had proven itself.

In other words, the Python standard library is written in Python for the 
exact same reasons that *any* software project might be written in Python.


-- 
Steven
0
Steven
7/17/2010 1:06:27 AM
Reply:

Similar Artilces:

python is a python
python is a python ...

Python mascot? How about a Pythoneer?
I've been thinking that a good Python mascot might help in raising public awareness of Python. The problem with a snake as a mascot is that it is not anthropomorphic enough. An effective mascot has to have something approximating two arms, two legs, and a head, so that he can be put into various interesting situations and adventures. (At the very least, he has to be able to work a keyboard and a mouse!) Good examples can be found in some of the imaginative things that have been done with Linux's Tux. So a snake is out. So are Terry Gilliam's wonderful cartoons for the Flyin...

Embedding Python in Python
Hi, I've been programming in Python for a couple of weeks now and am quite impressed with the language - it was very easy to learn (it actually reminds me a lot of programming in BASIC many many years ago - it's very fast to hack together a couple lines of code in interactive mode). I'm throwing together a simple little game (sort of a MUD-type thing) as my first 'big' project, and I thought it would be cool to be able to script the game in Python. Basically, I want to be able to type scripts in from within the game and attach them to objects, monsters, rooms, whatever. N...

Invoking Python from Python
Hi all, I have a need to create a Python script on the fly from another Python program and then execute the script so created. Do I need to invoke Python through os.spawnl or is there a better way? Thanks, -- John Am Tue, 08 Nov 2005 08:10:25 -0800 schrieb John Henry: > Hi all, > > I have a need to create a Python script on the fly from another Python > program and then execute the script so created. Do I need to invoke > Python through os.spawnl or is there a better way? Hi, creating source code with a script, is no good solution. Once I had to maintain lisp code which stored its data in lisp code, too (incl. conditions and loops). It was a nightmare. Please explain what you want to do, and we will find a better solution. HTH, Thomas -- Thomas G�ttler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de Spam Catcher: niemand.leermann@thomas-guettler.de In article <pan.2005.11.08.16.21.11.472836@thomas-guettler.de>, Thomas Guettler <niemand.leermann@thomas-guettler.de> wrote: . . . >creating source code with a script, is no good solution. > >Once I had to maintain lisp code which stored its data in lisp code, too >(incl. conditions and loops). It was a nightmare. > >Please explain what you want to do, and we will find a better solution. . . . Yes and no. There are times when it's justified. I ENTIRELY agree, though, that many people who *think* that's what they...

Python to Python communication
Hello, I have a group of Python programms which I want to teach to "talk to each other". All run on Windows, on the same computer or in the same intranet. Security of communication is not an issue (encryption on lower level protocols / intra computer communication). Partially these programs are using wxPython. It is important that the communcation is "only an added feature", I am not willing to spend big memory / computing ressources on it. So I googled and came up with at least the following opportunities: XMLRPC - quite "simple" to implement within python, contained in my favourite web framework Quixote / medusa SOAP - around the same amount of work as XMLRPC ----> these two are fully buzzword compatible to enterprise communication needs. But are they really lightwight and needed? Banana - within the twisted framework. Is described as high performance with very litte ressources. From my scanning of twisted it is meanwhile possible to integrate it within wxPython and you only need to sell the soul of your firstborn for it; but I got the impression twisted rather needs a total commitment than a "I just need some banana, man" pyro - Python Remote Objects. Irmen de Jong has a "get Firefox" icon on it's page and he plays with the name "pyro", which makes a good impression. It looks rather "ripe", but: he is talking about "pyro 4.0" which will be incompatible with pyro ...

Micro Python -- a lean and efficient implementation of Python 3
Hi, We would like to announce Micro Python, an implementation of Python 3 optimised to have a low memory footprint. While Python has many attractive features, current implementations (read CPython) are not suited for embedded devices, such as microcontrollers and small systems-on-a-chip. This is because CPython uses an awful lot of RAM -- both stack and heap -- even for simple things such as integer addition. Micro Python is a new implementation of the Python 3 language, which aims to be properly compatible with CPython, while sporting a very minimal RAM footprint, a compact c...

Python in the enterprise: "Python Slithers into Systems" / Why Python? (eweek 2007)
Last summers box office hit "snakes on a plane" was the unlikely story of a batch of snakes getting loose in flight on a 747. In what some might view as just as unlikely, ITA Software is using the Python language to empower its airline reservation system. Many computer language purists say that languages such as Java, C++ or C should be used for enterprise applications. However, ITA, a Cambridge, Mass., provider of airline IT software and services, is proving that dynamic languages such as Python can be rock-solid for enterprise work. Indeed, ITA in September 2006 announced an agreement with Montreal-based Air Canada, a subsidiary of ACE Aviation Holdings, to develop a new reservation management system for the airline. Air Canadas next- generation reservation system will include reservations, inventory control and seat availability, along with airport check-in and airport operations modules. Sean Menke, Air Canadas executive vice president and chief commercial officer, said the new system "will be a key instrument in Air Canadas strategy to maintain market leadership through product and customer differentiation. Moreover, it will provide unprecedented flexibility and significant cost savings." Leaving Legacy Behind Dan Kelley, director of application integration at ITA, said ITA will deliver the system to Air Canada next year, and it will be deployed across the entire Air Canada network, including reservation...

Python daemonisation with python-daemon
Hello there, I currently have a little project which involve the writing of a server that launch tasks when requested by the user (through a web interface for instance). I would like to turn my server script into a Linux/Unix daemon (launched at boot time by init, dunno if that matter) using the nice python-daemon package by Ben Finley et al (http://pypi.python.org/pypi/ python-daemon/). This package comes with a class DaemonRunner that seems to fit almost exactly my need but I still have some interrogation. My main class looks like the following: class SIGTERM_Received(Except...

embedding python in python #3
Hi, anyone had any experiences in embedding python in python? I've tried to do this but it doesn't work. eval("from Tkinter import *") Thanks maurice Use exec. On Wed, Sep 29, 2004 at 09:23:28AM +0000, Maurice LING wrote: > Hi, > > anyone had any experiences in embedding python in python? > > I've tried to do this but it doesn't work. > > eval("from Tkinter import *") Maurice LING <mauriceling@acm.org> wrote in message news:<415a7f0b$1@news.unimelb.edu.au>... > Hi, > > anyone had any experiences in embeddi...

Python 3 is killing Python
--047d7bfceec297d37804fa7abe05 Content-Type: text/plain; charset=UTF-8 Somthing I came across in my travels through the ether: https://medium.com/@deliciousrobots/5d2ad703365d/ --047d7bfceec297d37804fa7abe05 Content-Type: text/html; charset=UTF-8 <div dir="ltr"><div>Somthing I came across in my travels through the ether:<br></div><div><br></div><a href="https://medium.com/@deliciousrobots/5d2ad703365d/" target="_blank">https://medium.com/@deliciousrobots/5d2ad703365d/</a><br> </div> ...

Re: Python mascot? How about a Pythoneer?
Stephen Ferg <steve@ferg.org> wrote: > > I've been thinking that a good Python mascot might help in raising > public awareness of Python. > > The problem with a snake as a mascot is that it is not > anthropomorphic > enough....so a snake is out. > > So are Terry Gilliam's wonderful cartoons for the Flying Circus. > While wonderful, I just don't think they lend themselves to > mascot-hood. > > In that spirit, I propose the development of a figure representing > Python -- the Pythoneer. Given that Python users are traditionally ...

python 2 to python 3
I am using Wing101 v.5 and it is using Python2, but I want to make it = use Python3 instead because need Python3 for a uni lab. How do I = change it?= Audrey McFarlane wrote: > I am using Wing101 v.5 and it is using Python2, but I want to make it use > Python3 instead because need Python3 for a uni lab. How do I change it? I'm afraid I don't use Wing so I can't give a good answer, but I googled and found this: http://stackoverflow.com/questions/25318792/how-do-i-configure-wing101-to-run-python-3-3 It's not very helpful, but it might point you in th...

Python script to install python
I would like to have a python script that would download the most recent svn of python, configure, make, install and cleanup after itself. I am not replacing the python version I would be using to run the script. I was struggling to get this to work and I assume someone else has done it better. Any pointers? Thanks Vincent ...

Python from Smalltalk / Smalltalk from Python?
I am currently using a graphical package which is scripted with (integrated with) python. But I'd like to do my programming in smalltalk, thank you very much. How much of a hassle is it to connect python and smalltalk for this sort of thing? Anyone else done it? Is there a recommended approach? Tips? Suggestions? Pitfalls? (I have interfaced with C in the past, relatively painlessly, so I'm not a total newbie with this sort of thing) Thanks. pineapple.link@yahoo.com escreveu: > I am currently using a graphical package which is scripted with > (integrated with...

python-daemon for Python v3
Hi Community Is there ported to Python v3 python-daemon package? https://pypi.python.org/pypi/python-daemon/ i am afraid it is not as simple as correction of relative path input feature and except clauses in mentioned package. Thanks Asaf Asaf Las <roegltd@gmail.com> writes: > Is there ported to Python v3 python-daemon package? > > https://pypi.python.org/pypi/python-daemon/ Have a read through the archives for the ‘python-daemon-devel’ discussion forum <URL:http://lists.alioth.debian.org/mailman/listinfo/python-daemon-devel>, where we have ...

Using Python To Launch Python
Hello All, I have a situation where I can count on a Python installation being available on a system, but I can't count on it being a version of Python needed by my application. Since my application has it's own version of Python installed with it how should I use the system Python to launch the version of Python that launches my Application. Yes, this is a convoluted process, but not all Pythons are built the same :) Right now I am leaning towards using exec to start a new process, but I thought I would check to see if anyone else has had the need to perform a task similar to thi...

Embedding Python in Python #2
Anyone know a good way to embed python within python? Now before you tell me that's silly, let me explain what I'd like to do. I'd like to allow user-defined scriptable objects. I'd like to give them access to modify pieces of my classes. I'd like to disallow access to pretty much the rest of the modules. Any ideas/examples? -Robey You probably want something like this: globalDict = {} exec(stringOfPythonCodeFromUser, globalDict) globalDict is now the global namespace of whatever was in stringOfPythonCodeFromUser, so you can grab values from that and selectivly im...

python/python output buffers
Hi, I'm having a little problem while using python mode. I'm used to hit C-c C-c and have a Python Output buffer opened with the output. Now, on Ubuntu 7.10 and 8.04, C-c C-c sends to the Python buffer that is not raised in a window. I need to hit C-c C-z to see it. First of all I'm puzzled and would like to understand what makes the difference. I guess is some defaults that changed in the system configuration. What makes the difference between the two behaviors? Thanks in advance sandro *:-) sandro dentella a �crit : > Hi, > > I'm having a little proble...

ActivePython or Python from Python.org
Hi everyone. I noticed that ActiveState has their own variation of Python and was curious if there's a benefit to choosing their version over the version offered via Python.org. Could someone lend some insight? Thanks, Rey... Rey Bango wrote: > Hi everyone. I noticed that ActiveState has their own variation of > Python and was curious if there's a benefit to choosing their version > over the version offered via Python.org. > > Could someone lend some insight? Here is some reasoning I wrote a while back: http://mail.python.org/pipermail/python-list/2007-July/447987...

Python's and and Pythons or
I really like the logic that Pythons "or" is not only short-circuit but non-typed. So I can say y = override or default and y won't necc be True or False. If override boolean evaluates to True (which, for most classes, means not None) than y will be equal to override. Otherwise it will be equal to default. I have two questions --> Is there a handy name for this type of conditional (something as catchy as "short circuit or") and --> Is there a common idiom for taking advantage of the similar behavior of "and". The "override or def...

Re: Micro Python -- a lean and efficient implementation of Python 3
On Tue, 10 Jun 2014 12:27:26 -0700, wxjmfauth wrote: > Le samedi 7 juin 2014 04:20:22 UTC+2, Tim Chase a écrit : >> On 2014-06-06 09:59, Travis Griggs wrote: >> >> > On Jun 4, 2014, at 4:01 AM, Tim Chase wrote: >> >> > > If you use UTF-8 for everything >> >> >> > >> > It seems to me, that increasingly other libraries (C, etc), use >> >> > utf8 as the preferred string interchange format. >> >> >> >> I definitely advocate UTF-8 for any streaming scen...

python-list@python.org
Has anyone got a simple python script that will parse a linux mbox and create a large file to view . I need to write a python program the grabs mail from a standard linux mail folder and processes it to file to eventually be transfered to a database. Im having problems at the moment can someone post a exmaple or no if a similar script exists to hack. Not to good with Python and I have'nt got alot of time to get to grips with writing my own. Cheers Chuck ...

How to run python without python
Is there a way to developing a script on linux and give it to someone on microsoft, so that they could run it on microsoft without installing python? Wayne ...

python QT or python-GTK
** All the posts found in google are old. I'm assuming new improvements have been made to both IDEs. ** Please correct me if I'm wrong, I'm a newbie. 1. Which one of them requires fewer lines to accomplish the same thing? from what I understand QT it's just like Borland J-Builder. Meaning, you want a button, you draw it, then you double-click on it, a window opens up and you type events and behavior. And with GTK, you just type everything. 2. Which one is cross platform? (Linux, MacOS, Windows,etc). 3. Which one has more widgets? 4. Which one is the easiest to pick up? I...

Web resources about - Subsets of Python implemented in Python - comp.lang.python

Facebook Details Privacy Measures Implemented With Launches Of New Ad Products
Facebook posted a note on its Facebook Privacy page to reassure users of the social network that their privacy remained top of mind during the ...

Tony Abbott wants fewer 'visually awful' wind farms, wishes Howard government never implemented Renewable ...
... Tony Abbott has described wind farms as "visually awful", saying he wishes the Howard government, of which he was a member, had never implemented ...

Spencer: CPAC Is a 'Sharia-Compliant Conference' Where Islamic Law Has Been Implemented - YouTube
http://www.rightwingwatch.org/content/spencer-cpac-sharia-compliant-conference-where-islamic-law-has-been-implemented Robert Spencer says that ...

Free bus service implemented in Chengdu city (2) - People's Daily Online
... & Culture - Travel - Sports - Science - Education - Photo - Tibet Online - Special Coverage English >> China Society Free bus service implemented ...

Jones County Pay Scale to Be Implemented Dec. 1
Jones County employees now have a fixed starting salary and a way to get raises under a standard pay scale approved by the county commission. ...

QUOTE: Once an innovation is implemented it is no longer innovative.
Once an innovation is implemented it is no longer innovative. —Jack Anderson, Chevron (via @bmoesta )

Free Advice, When Perfectly Implemented, Adds Up To Serious Cash
... subsides. The firm’s service to the community is action, and actions are more memorable than words. The post Free Advice, When Perfectly Implemented, ...

Rwanda Calls for Cessation Clause to Be Implemented
The government has called on the United Nations High Commission for Refugees (UNHCR) to revitalise the implementation of the Cessation Clause ...

Chances that injunction preventing immigration orders being implemented will be overturned are slim
The Department of Justice is appealing a decision by a Texas circuit court judge that granted an injunction preventing implementation of the ...

Gorgeous Journal App Day One Gains Nicely Implemented PDF Export Feature
... You can download Day One for Mac in the Mac App Store for $9.99. Day One (Journal / Diary) Gorgeous Journal App Day One Gains Nicely Implemented ...

Resources last updated: 2/25/2016 12:35:32 AM