Friday, October 29, 2021

Python Bytes: #256 And the best open source project prize goes to ...

<p><strong>Watch the live stream:</strong></p> <a href='https://www.youtube.com/watch?v=ZrcwAIix9UA' style='font-weight: bold;'>Watch on YouTube</a><br> <br> <p><strong>About the show</strong></p> <p>Sponsored by <strong>Shortcut - Get started at</strong> <a href="http://shortcut.com/pythonbytes"><strong>shortcut.com/pythonbytes</strong></a></p> <p>Special guest: <strong>The Anthony Shaw</strong></p> <p><strong>Michael #0: It’s episode 2^8 (nearly 5 years of podcasting)</strong></p> <p><strong>Brian #1:</strong> <a href="https://lukasz.langa.pl/f15a8851-af26-4e94-a4b1-c146c57c9d20/"><strong>Where does all the effort go?</strong></a><a href="https://lukasz.langa.pl/f15a8851-af26-4e94-a4b1-c146c57c9d20/"><strong>:</strong></a> <a href="https://lukasz.langa.pl/f15a8851-af26-4e94-a4b1-c146c57c9d20/"><strong>Looking at Python core developer activity</strong></a></p> <ul> <li>Łukasz Langa</li> <li>A look into CPython repository history and PR data</li> <li>Also, nice example of datasette in action and lots of SQL queries. </li> <li>The data, as well as the process, is open for anyone to look at.</li> <li>Cool that the process was listed in the article, including helper scripts used.</li> <li>Timeframe for data is since Feb 10, 2017, when source moved to GitHub, through Oct 9, 2021. <ul> <li>However, some queries in the article are tighter than that.</li> </ul></li> <li>Queries <ul> <li>Files involved in PRs since 1/1/20 <ul> <li>top is ceval.c with 259 merged PRs</li> </ul></li> <li>Contributors by number of merged PRs <ul> <li>lots of familiar names in the top 50, along with some bots</li> <li>it’d be fun to talk with someone about the bots used to help the Python project</li> <li>nice note: “Clearly, it pays to be a bot … or a release manager since this naturally causes you to make a lot of commits. But Victor Stinner and Serhiy Storchaka are neither of these things and still generate amazing amounts of activity. Kudos! In any case, this is no competition but it was still interesting to see who makes all these recent changes.”</li> </ul></li> <li>Who contributed where? <ul> <li>Neat. There’s a self reported <a href="https://devguide.python.org/experts/">Experts Index</a> in the very nice <a href="https://devguide.python.org/">Python Developer’s Guide</a>. But some libraries don’t have anyone listed. The data does though. </li> <li>Łukasz generated a <a href="https://lukasz.langa.pl/f15a8851-af26-4e94-a4b1-c146c57c9d20/assets/all_experts.txt">top-5 list</a> for each file. Contributing to some file and have a question. These folks may be able to help.</li> </ul></li> <li>Averages for PR activity <ul> <li>core developer authoring and merging their own PR takes on average <strong>~7</strong> days (std dev <strong>±41.96</strong> days);</li> <li>core developer authoring a PR which was merged by somebody else takes on average <strong>20.12</strong> days (std dev <strong>±77.36</strong> days);</li> <li>community member-authored PRs get merged on average after <strong>19.51</strong> days (std dev <strong>±81.74</strong> days).</li> <li>Interesting note on those std deviations: “Well, if we were a company selling code review services, this standard deviation value would be an alarmingly large result. But in our situation which is almost entirely volunteer-driven, the goal of my analysis is to just observe and record data. The large standard deviation reflects the large amount of variation but isn’t necessarily something to worry about. We could do better with more funding but fundamentally our biggest priority is keeping CPython stable. Certain care with integrating changes is required. Erring on the side of caution seems like a wise thing to do.”</li> </ul></li> </ul></li> <li>More questions to be asked, especially from the issue tracker <ul> <li>Which libraries require most maintenance?</li> </ul></li> </ul> <p><strong>Michael #2:</strong> <a href="https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html"><strong>Why you shouldn't invoke setup.py directly</strong></a></p> <ul> <li>By <a href="https://blog.ganssle.io/author/paul-ganssle.html">Paul Ganssle</a> (from <a href="https://talkpython.fm/episodes/show/271/unlock-the-mysteries-of-time-pythons-datetime-that-is"><strong>Talk Python #271: Unlock the mysteries of time, Python's datetime that is!</strong></a>)</li> <li>In response to conversation in <a href="https://talkpython.fm/episodes/show/338/using-cibuildwheel-to-manage-the-scikit-hep-packages"><strong>Talk Python’s cibuildwheel episode</strong></a>?</li> <li>For a long time, <a href="https://github.com/pypa/setuptools">setuptools</a> and distutils were the only game in town when it came to creating Python packages</li> <li>You write a setup.py file that invokes the setup() method, you get a Makefile-like interface exposed by invoking python setup.py [HTML_REMOVED]</li> <li>The last few years <strong>all direct invocations of setup.py are effectively deprecated</strong> in favor of invocations via purpose-built and/or standards-based CLI tools like <a href="https://pip.pypa.io/en/stable/">pip</a>, <a href="https://pypa-build.readthedocs.io/en/stable/">build</a> and <a href="https://tox.wiki/en/latest/">tox</a>.</li> <li>In Python 2.0, the distutils module was introduced as a standard way to convert Python source code into *nix distro packages</li> <li>One major problem with this approach, though, is that every Python package <em>must</em> use distutils and <em>only</em> distutils — there was no standard way for a package author to make it clear that you need <em>other</em> packages in order to build or test your package. =&gt; Setuptools</li> <li>Works, but sometimes you need requirements before the install (see cython example)</li> <li>A <strong>build backend</strong> is something like setuptools or <a href="https://flit.readthedocs.io/en/latest/">flit</a>, which is a library that knows how to take a source tree and turn it into a distributable artifact — a source distribution or a wheel.</li> <li>A <strong>build frontend</strong> is something like pip or <a href="https://pypa-build.readthedocs.io/en/stable/">build</a>, which is a program (usually a CLI tool) that orchestrates the build environment and invokes the build backend</li> <li>In this taxonomy, setuptools has historically been <em>both</em> a backend <em>and</em> a frontend - that said, setuptools is a <em>terrible</em> frontend. It does not implement PEP 517 or PEP 518's requirements for build frontends</li> <li>Why am I not seeing deprecation warnings?</li> <li>Use <a href="https://pypa-build.readthedocs.io/en/latest/"><strong>build package</strong></a>.</li> <li>Also can be replaced by <a href="https://tox.wiki/en/latest/">tox</a>, <a href="https://nox.thea.codes/en/stable/index.html">nox</a> or even a Makefile</li> <li>Probably should just check out <a href="https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html#summary"><strong>the summary table</strong></a>.</li> </ul> <p><strong>Anthony #3:</strong> <a href="https://opentelemetry.io"><strong>OpenTelemetry is going stable soon</strong></a></p> <ul> <li>Cloud Native Computing Foundation project for cross-language event tracing, performance tracing, logging and sampling for distributed applications.</li> <li>Engineers from Microsoft, Amazon, Splunk, Google, Elastic, New Relic <a href="https://opentelemetry.io/vendors/">and others</a> working on standards and specification.</li> <li>Formed through a merger of the OpenTracing and OpenCensus projects.</li> <li>Python SDK supports instrumentation of <a href="https://opentelemetry.io/registry/">lots of frameworks</a>, like Flask, Django, FastAPI (ASGI), and ORMs like SQLalchemy, or templating engines.</li> <li>All data can then be exported onto various platforms : NewRelic, Prometheus, Jaeger, DataDog, Azure Monitor, Google Cloud Monitoring.</li> </ul> <p>If you want to get started and play around, checkout the rich console exporter I submitted recently.</p> <p><strong>Brian #4:</strong> <a href="https://sadh.life/post/builtins/"><strong>Understanding all of Python, through its builtins</strong></a></p> <ul> <li>Tushar Sadhwani</li> <li>I really enjoyed the discussion before he actually got to the builtins. <ul> <li>LEGB rule defines the order of scopes in which variables are looked up in Python. <ul> <li>Local, Enclosing (nonlocal), Global, Builtin</li> </ul></li> <li>Understanding LEGB is a good thing to do for Python beginners or advanced beginners. Takes a lot of the mystery away.</li> <li>Also that all the builtins are in one </li> </ul></li> <li>The rest is a quick scan through the entire list. <ul> <li>It’s not detailed everywhere, but pulls over scenic viewpoints at regular intervals to discuss interesting parts of <code>builtins</code>.</li> <li>Grouped reasonably. Not alphabetical</li> </ul></li> <li>Constants: There’s exactly 5 constants: <code>True</code>, <code>False</code>, <code>None</code>, <code>Ellipsis</code>, and <code>NotImplemented</code>.</li> <li>globals and locals: Where everything is stored</li> <li>bytearray and memoryview: Better byte interfaces</li> <li>bin, hex, oct, ord, chr and ascii: Basic conversions</li> <li>…</li> <li>Well, it’s a really long article, so I suggest jumping around and reading a section or two, or three. Luckily there’s a nice TOC at the top.</li> </ul> <p><strong>Michael #5:</strong> <a href="https://www.infoworld.com/article/3637038/the-best-open-source-software-of-2021.html#slide5"><strong>FastAPI, Dask, and more Python goodies win best open source titles</strong></a></p> <ul> <li>Things that stood out to me</li> <li>FastAPI</li> <li>Dask</li> <li>Windows Terminal</li> <li>minikube - Kubernetes cluster on your PC</li> <li>OBS Studio</li> </ul> <p><strong>Anthony #6:</strong> <a href="https://lukasz.langa.pl/5d044f91-49c1-4170-aed1-62b6763e6ad0/"><strong>Notes From the Meeting On Python GIL Removal Between Python Core and Sam Gross</strong></a></p> <ul> <li>Following on from last week’s share on the “nogil” branch by Sam Gross, the Core Dev sprint included an interview.</li> <li>Targeted to 3.9 (alpha 3!), needs to at least be updated to 3.9.7. </li> </ul> <p>Nogil:</p> <ul> <li>Replaces pymalloc with mimalloc for thread safety</li> <li>Ties objects to the thread that created them witha. non-atomic local reference count within the owner thread</li> <li>Allows for (slower) reference counting from other threads.</li> <li>Immortalized some objects so that references never get inc/dec’ed like True, False, None, etc.</li> <li>Deferred reference counting</li> <li>Adjusts the GC to wait for all threads to pause at a safe point, doesn’t wait for I/O blocked threads and constructs a list of objects to deallocate using mimalloc</li> <li>Relocates the MRO to a thread local (instead of process-local) to avoid contention on ref counting</li> <li>Modifies the builtin collections to be thread-safe (lists, dictionaries, etc,) since they could be shared across threads.</li> </ul> <p>IMHO, biggest thing to happen to Python in 5 years. Encouragingly, Sam was invited to be a Core Dev and Lukasz will mentor him!</p> <p><strong>Extras</strong></p> <p>Michael</p> <ul> <li><a href="https://twitter.com/ThePSF/status/1450168556801380357"><strong>Python Developers Survey 2021</strong></a> is open</li> <li><a href="https://twitter.com/HenrySchreiner3/status/1451210681827659781"><strong>More PyPI CLI updates</strong></a></li> <li><a href="https://github.com/c4urself/bump2version/"><strong>bump2version</strong></a> via Bahram Aghaei (youtube comment)</li> <li>Was there <a href="http://mellifera.cc/wp-content/uploads/2008/10/mic-insertion2.jpg"><strong>a bee stuck in Brian’s mic</strong></a> last time?</li> </ul> <p>Brian</p> <ul> <li><a href="https://us.pycon.org/2022/speaking/speaking/"><strong>PyCon US 2022 CFP is open until Dec 20</strong></a> </li> <li><a href="https://pragprog.com/titles/bopytest2/python-testing-with-pytest-second-edition/"><strong>Python Testing with pytest, 2nd edition, Beta 7.0</strong></a> <ul> <li>All chapters now there. (Final chapter was “Advanced Parametrization”)</li> <li>It’s in technical review phase now. </li> <li>If reading, please skip ahead to the chapter you really care about and submit errata if you find anything confusing.</li> </ul></li> </ul> <p><strong>Joke:</strong></p> <p><img src="https://ift.tt/3blfY2Q" alt="" /></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...