Python Written in C?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Warren Myers

    #61
    Re: Python Written in C?

    The OO overheads for C++ are almost non-existent.


    On Mon, Jul 21, 2008 at 2:05 PM, Dan Upton <upton@virginia .eduwrote:
    On Mon, Jul 21, 2008 at 1:21 PM, Marc 'BlackJack' Rintsch
    <bj_666@gmx.net wrote:
    >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;re turn 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.
    --

    >


    --

    Warren Myers

    Comment

    • Tim Rowe

      #62
      Re: Python Written in C?

      2008/7/21 Krishnakant Mane <hackingkk@gmai l.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

      Comment

      Working...