Saturday, November 28, 2020

Python Bytes: #209 JITing Python with .NET, no irons in sight

<p>Sponsored by us! Support our work through:</p> <ul> <li>Our <a href="https://training.talkpython.fm/"><strong>courses at Talk Python Training</strong></a></li> <li><a href="https://testandcode.com/"><strong>Test &amp; Code</strong></a> Podcast</li> <li><a href="https://www.patreon.com/pythonbytes"><strong>Patreon Supporters</strong></a></li> </ul> <p><strong>Michael #1:</strong> <a href="https://tonybaloney.github.io/posts/running-python-on-dotnet-5-with-pyjion.html"><strong>Running Python on .NET 5</strong></a></p> <ul> <li>by Anthony Shaw</li> <li>Talked about <a href="https://talkpython.fm/episodes/show/49/microsofts-jit-based-python-project-pyjion">pyjion way back when on episode 49 with Brett Cannon</a>.</li> <li>.NET 5 was released on November 10, 2020. It is the cross-platform and open-source replacement of the <a href="https://github.com/dotnet/core"><strong>.NET Core</strong></a> project and the <strong>.NET</strong> project that ran exclusively on Windows since the late 90’s. See <a href="https://www.youtube.com/playlist?list=PLdo4fOcmZ0oVWop1HEOml2OdqbDs6IlcI">the conference about it</a> if you want to go deeper.</li> <li>Performance: I just saw a SO post about someone <a href="https://stackoverflow.com/questions/29903320/why-is-my-computation-so-much-faster-in-c-sharp-than-python">complaining their Python was 31x slower than C#</a>.</li> <li>The most common way around this performance barrier is to compile Python extensions from C or using something like Cython.</li> <li>.NET 5 CLR comes bundled with a performant JIT compiler (codenamed RyuJIT) that will compile .NETs IL into native machine instructions on Intel x86, x86-64, and ARM CPU architectures.</li> <li>Pyjion is a project to replace the core execution loop of CPython by transpiling CPython bytecode to ECMA CIL and then using the .NET 5 CLR to compile that into machine code.</li> <li>It then executes the machine-code compiled JIT frames at runtime instead of using the native execution loop of CPython.</li> <li>A few releases of Python ago (CPython specifically, the most commonly used version of Python) in 3.7 a new API was added to be able to swap out “frame execution” with a replacement implementation. This is otherwise known as <a href="https://www.python.org/dev/peps/pep-0523/">PEP 523</a>.</li> <li>This extension uses the same standard library as Python 3.9.</li> <li>Will this be compatible with my existing Python code? What about C Extensions? <ul> <li>The short answer is- if your existing Python code runs on CPython 3.9 – <strong>yes</strong> it will be compatible.</li> <li>Tested against the full CPython “test suite” on all platforms. In fact, it was the first JIT ever to pass the test suite.</li> </ul></li> <li>Is this faster? The short answer a little, but not by much (yet).</li> <li>see also: https://twitter.com/anthonypjshaw/status/1328457723608928256?s=20 </li> </ul> <p><strong>Brian #2:</strong> <a href="https://www.python.org/dev/peps/pep-0621/"><strong>PEP 621 -- Storing project metadata in pyproject.toml</strong></a></p> <ul> <li>Progress on standardizing what goes into pyproject.toml</li> <li>Authors Brett Cannon, Paul Ganssle, Pradyun Gedam, Sébastien Eustace (of poetry), Thomas Kluyver (of flit), Tzu-Ping Chung</li> <li>Motivators of this PEP are: <ul> <li>Encourage users to specify core metadata statically for speed, ease of specification, unambiguity, and deterministic consumption by build back-ends</li> <li>Provide a tool-agnostic way of specifying metadata for ease of learning and transitioning between build back-ends</li> <li>Allow for more code sharing between build back-ends for the "boring parts" of a project's metadata</li> </ul></li> <li>Doesn’t change any existing core metadata</li> <li>Doesn’t attempt to standardize all possible metadata</li> <li>Included in table named <code>[project]</code>: <ul> <li>name</li> <li>version</li> <li>description</li> <li>readme</li> <li>requires-python</li> <li>license</li> <li>authors/maintainers</li> <li>keywords</li> <li>classifiers</li> <li>urls</li> <li>entry points</li> <li>dependencies/optional-dependencies</li> <li>dynamic </li> </ul></li> <li>There’s an example in the PEP that helps clear things up</li> <li>Many items have synonyms specified for flit/poetry/setuptools (presumably for backward compatibility)</li> </ul> <p><strong>Michael #3:</strong> <a href="https://www.engadget.com/github-youtube-dl-aftermath-222301386.html"><strong>GitHub revamps copyright takedown policy after restoring YouTube-dl</strong></a></p> <ul> <li>In October following a DMCA complaint from the Recording Industry Association of America (RIAA) it was taken down at GitHub. </li> <li>Citing a <a href="https://github.com/github/dmca/blob/master/2020/11/2020-11-16-RIAA-reversal-effletter.pdf">letter</a> from the Electronic Frontier Foundation (the EFF), GitHub says it ultimately found that the RIAA’s complaint didn’t have any merit. </li> <li>The RIAA argued the tool ran afoul of section 1201 of the US copyright law by giving people the means to circumvent YouTube’s DRM. </li> <li>the EFF dissects the RIAA’s claims, highlighting where the organization had either misinterpreted the law or how the code of YouTube-dl works. “Importantly, YouTube-dl does not decrypt video streams that are encrypted with commercial DRM technologies, such as Widevine, that are used by subscription videos sites, such as Netflix,” the organization points out when it comes to the RIAA’s primary claim.</li> <li>GitHub is implementing new policies to avoid a repeat of a repeat situation moving forward. First, it says a team of both technical and legal experts will manually evaluate every single section 1201 claim.</li> <li>If the company’s technical and legal teams ultimately find any issues with a project, GitHub will give its owners the chance to address those problems before it takes down their work.</li> <li>GitHub is establishing a $1 million legal defense fund for developers.</li> <li>Sidebar: EFF has just launched <a href="https://www.eff.org/deeplinks/2020/11/introducing-how-fix-internet-new-podcast-eff"><em>How to Fix the Internet</em></a>, a new podcast mini-series that examines potential solutions to six ills facing the modern digital landscape.</li> </ul> <p><strong>Brian #4:</strong> <a href="https://developer.mongodb.com/how-to/mongodb-on-raspberry-pi"><strong>Install &amp; Configure MongoDB on the Raspberry Pi</strong></a></p> <ul> <li>Mark Smith</li> <li>Definitely a “wow, I didn’t know you could do that” article.</li> <li>Tutorial walks through <ul> <li>Installing 64 bit Ubuntu Server on a Raspberry Pi</li> <li>Configure wifi</li> <li>Install MongoDB on Pi</li> <li>Set up a user account, to safely expose MongoDB on a home network.</li> <li>Now you’ve got a MongoDB server in your house. So cool</li> </ul></li> </ul> <p><strong>Michael #5: Extra! extra! extra!, hear all about it!</strong></p> <ul> <li><a href="https://twitter.com/jmnickerson/status/1327640465102016515">Follow up</a> on my critique of things like SQL &amp; CSS put next to Python and Java. Maybe best to grab the conversation from <a href="https://twitter.com/mkennedy/status/1328029407752065025">here</a>.</li> <li>Guido joins Microsoft, <a href="https://twitter.com/gvanrossum/status/1326932991566700549">why</a>? People seem to see this as a positive for sure. But they <a href="https://twitter.com/edxplore/status/1327420845031972866">checked him out</a>!</li> <li>New code editor roaming the streets: <a href="https://www.nova.app/">Nova</a> from Panic.</li> <li>Two thumbs up on Big Sur and now waiting on the Mac Mini M1.</li> </ul> <p><strong>Brian #6:</strong> <a href="https://daleonai.com/social-media-fashion-ai"><strong>A Python driven AI Stylist Inspired by Social Media</strong></a></p> <ul> <li>Dale Markowitz</li> <li>A bunch of Google tools (cloud storage, firebase, cloud vision api, product search api)</li> <li>Some React for front end</li> <li>Python to batch script</li> <li>General oversimplified process: <ul> <li>photos from social media for inspiration</li> <li>photos of everything in your closet, multiple of each item</li> <li>use AI suggest outfits from your closet that match inspiration photos</li> </ul></li> <li>Ok. The process is really more of a promo for Google AI products, and not so much about Python, but it’s a cool “look what you can do with software” kinda thing.</li> <li>Also, many of the tools used by online retail, like “similar products” and such, are available to lots of people now, and that’s cool.</li> </ul> <p>Joke:</p> <p><a href="https://devhumor.com/media/commitstrip-never-lose-hope">Back to the [dev] future!</a></p> <p><img src="https://ift.tt/3fH7Drw" alt="[commitstrip] Never lose hope" /></p>

from Planet Python
via read more

No comments:

Post a Comment

TestDriven.io: Working with Static and Media Files in Django

This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...