Anyone done much with NodeJS and open APIs (github, google docs, etc)? Anyone done much with NodeJS and open APIs (github, google docs, etc)? - Page 2
Page 2 of 2 FirstFirst 12
Posts 11 to 15 of 15
  1. #11

    More time posting than coding

    TheGreenBastard's Avatar
    Join Date
    Dec 2015
    Posts
    493

    Default

    Quote Originally Posted by darrylmg View Post
    Are you certain Python gets compiled?
    I know you can make a Python script portable by wrapping it with the interpreter, but I honestly didn't imagine any bytecode was ever produced. If it was possible to produce bytecode then wouldn't people distribute some of their stuff as bytecode for performance reasons? I've not noticed any (could be me not being very observant though).

    Sent from my SM-T280 using Contractor UK Forum mobile app
    You can output bytecode and distribute it, but there's no performance benefit outside of startup cost when compared to a Python source file, you just jump the bytecode compilation step.

  2. #12

    My post count is Majestic

    NickFitz's Avatar
    Join Date
    Jun 2007
    Location
    Your local branch
    Posts
    44,598

    Default

    Quote Originally Posted by darrylmg View Post
    Are you certain Python gets compiled?
    I know you can make a Python script portable by wrapping it with the interpreter, but I honestly didn't imagine any bytecode was ever produced. If it was possible to produce bytecode then wouldn't people distribute some of their stuff as bytecode for performance reasons? I've not noticed any (could be me not being very observant though).

    Sent from my SM-T280 using Contractor UK Forum mobile app
    If you look in a directory containing Python code that's been run, you'll see that each .py file has a corresponding .pyc file, which is the compiled bytecode - for Python 3, they'll be in a __pychache__ subdirectory, but Python 2 had them alongside each other. The compilation step happens when a file is first loaded by the Python interpreter, is very fast, and is only done again if the source file has changed, so there's no real performance advantage to distributing the bytecode. In fact, I see that some examples on my own machine that have been run under Python 3.6 have a -36 suffix before the .pyc extension, so presumably they are tied to that version, which would prevent me upgrading to 3.7 if they were all I had.

    More on Python bytecode: An introduction to Python bytecode | Opensource.com, Understanding Python bytecode | Synopsys
    Last edited by NickFitz; 20th February 2019 at 13:48.

  3. #13

    More time posting than coding

    darrylmg's Avatar
    Join Date
    Sep 2012
    Location
    UK - South West
    Posts
    265

    Default

    Quote Originally Posted by NickFitz View Post
    If you look in a directory containing Python code that's been run, you'll see that each .py file has a corresponding .pyc file, which is the compiled bytecode - for Python 3, they'll be in a __pychache__ subdirectory, but Python 2 had them alongside each other. The compilation step happens when a file is first loaded by the Python interpreter, is very fast, and is only done again if the source file has changed, so there's no real performance advantage to distributing the bytecode. In fact, I see that some examples on my own machine that have been run under Python 3.6 have a -36 suffix before the .pyc extension, so presumably they are tied to that version, which would prevent me upgrading to 3.7 if they were all I had.

    More on Python bytecode: An introduction to Python bytecode | Opensource.com, Understanding Python bytecode | Synopsys
    Thanks.
    It's freaky how things work out sometimes.
    Literally the day after thegreenbastard confirmed about the bytecode thing, I was requested to see if I could find a way of getting some Python 2.7 code running on a RHEL 6.7 server (2.6 only, unless you install some community repo stuff) without involving the Linux admin team (uh oh).
    So away I went to read all about bytecode to see if I could somehow shortcut some issues I was seeing in my quest to not involve the admin team (they really are miserable and I work in a heavily politicised environment).
    Now if we could just discuss next week's lottery result...

    Sent from my SM-T280 using Contractor UK Forum mobile app
    Don't believe it, until you see it!

  4. #14

    Fingers like lightning

    Cirrus's Avatar
    Join Date
    Oct 2015
    Location
    Rural Rutland
    Posts
    992

    Default

    Quote Originally Posted by darrylmg View Post
    Are you certain Python gets compiled?
    As ever, Google is your friend.
    "Don't part with your illusions; when they are gone you may still exist, but you have ceased to live" Mark Twain

  5. #15

    More time posting than coding

    darrylmg's Avatar
    Join Date
    Sep 2012
    Location
    UK - South West
    Posts
    265

    Default

    Quote Originally Posted by Cirrus View Post
    As ever, Google is your friend.
    I get your point, but I don't agree with it.
    I think asking questions on here enlightens more than just the OP, can open the space to ideas, allows us to connect with each other and draws traffic (and maybe new members).
    As an example, I now know that yourself and nickfitz know about Python. In return you know that I mess about with Red Hat and CentOS. Someone might find this thread (ironically via a Google search - I know) and decide to join and contribute.

    For anyone interested, my only bit of Python that I have written is actually executed via stdin, inline inside a HERE document in a Korn shell script. You don't get any bytecode output, I looked. Checked with strace after nickfitz confirmed.
    Would I get a performance benefit from moving it out to a separate python script? Maybe. I might give it a go.
    I also got the whole Python 3 stuff ported across from CentsOS 6.7 to RHEL 6.7 using the SCL to get it downloaded on CentOS, then just copy across to RHEL and adjust the shebangs for the new target location path. Works a treat and completely RPM-less.

    I also saw a nice demo last week, using CDS to very quickly create a model and deploy to sqllite before running it on node.js for the generated oData service. Unbelievably slick! Might give node.js a try out on Azure.
    If you're looking at node.js, I highly recommend looking at CDS for node.


    Sent from my SM-T280 using Contractor UK Forum mobile app
    Don't believe it, until you see it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •