I always used Python as a CLI calculator. "But Python is an interpreted language and therefore slower than C". Me:

  • 2
  • 4
    Okay, acceptable
  • 1
    Slower than C... I think this depends more upon your algorithm and whether or not you push the python interpreter to call the internal functions correctly. If you don't program idiomatic python it will be really slow. Also, python does have JIT interpreters available. There are also modules that allow you to decorate a function that will be compiled to machine code. Then there is opencl and opencv libraries.

    Also, programmer time is often more important than execution speed. Especially for quick one off scripts.
  • 3
    Cool trick, OP ;)

    @Demolishun blah blah blah
    Python is slower than C and will always be, even with compilers like numba.
    But yeah, it has its uses
  • 2
    Oh well nice 😂

    While that's true, it's not important in your use case.

    I mean it's more convenient to just whip up something on Python CLI than write and compile a full C program.
  • 0
    @MagicSowap You understand the JIT interpreters have the potential to be faster than compiled code right? I believe the V8 can use runtime metrics and information to further optimize the machine code it produces. This information it not available to a traditional compiler.
  • 1
    @Demolishun Just no.

    Also, ever heard about Profile Guided Optimization (PGO) (also called FGO) ?
    (gcc -fprofile-use & gcc -fauto-profile)
  • 0
Add Comment