Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

Mark H Harris harrismh777 at gmail.com
Sat Apr 5 01:23:58 EDT 2014


On 4/4/14 11:49 PM, Chris Angelico wrote:
> On Sat, Apr 5, 2014 at 3:31 PM, Mark H Harris <harrismh777 at gmail.com> wrote:
>>     Its has always seemed to me that Java or C++ would be better suited to
>> creating python. I wonder will C always be the standard canonical PSF python
>> interpreter base language? Has the C python community considered making the
>> standard base language Java or C++ ?
>
> what's the advantage of C++ over C?
> A Python interpreter needs to do broadly this:
>
> 1) Parse a text file into an abstract syntax tree
> 2) Compile the AST into bytecode
> 3) Execute the bytecode:
> 3a) Manage object lifetimes and garbage collection
> 3b) Perform lower-level calls
> 3c) Efficiently handle namespaces etc
>

The only advantage of C++ over C is polymorphism, really. There are in 
my view only three reasons to even use C++: 1) the iostream library, and 
2) polymorphism, and 3) operator overloading. If you need to do all 
three, then C++ is a really good candidate.

I am still thinking about the concept of unifying Number; Number as a 
C++ abstract base class, and an entire Class hierarchy which carries 
through making *any* Number just work. The ability of the C++ compiler 
to construct and maintain the virtual function tables would be an 
advantage. Operator overloading (and maybe templates) would make C++ 
advantageous also.

Guido told me that the modern C python is object oriented. Operator 
overloading is a big part of this. It seems to me that a modern object 
oriented language would best be implemented with a true object oriented 
base language, C++ rather than C.  I have always questioned this, just 
curious why the decision for C was made--- historically, 
methodologically, and maybe scientifically.

It would be tons of work, but maybe not as much as one might think, 
initially.


marcus





More information about the Python-list mailing list