DiscoverPython Bytes
Python Bytes
Claim Ownership

Python Bytes

Author: Michael Kennedy and Brian Okken

Subscribed: 3,162Played: 30,736
Share

Description

Python Bytes is a weekly podcast hosted by Michael Kennedy and
Brian Okken. The show is a short discussion on the headlines and noteworthy news
in the Python, developer, and data science space.
131 Episodes
Reverse
Sponsored by DigitalOcean: pythonbytes.fm/digitaloceanBrian #1: PEP 581 (Using GitHub issues for CPython) is acceptedPEP 581The email announcing the acceptance.“The migration will be a large effort, with much planning, development, and testing, and we welcome volunteers who wish to help make it a reality. I look forward to your contributions on PEP 588 and the actual work of migrating issues to GitHub.” — Barry WarsawMichael #2: Replace Nested Conditional with Guard ClausesDeeply nested code is problematic (does it have deodorant — err comments?)But what can you do? Guard clauses!See Martin Fowler’s article and this one. # BAD! def checkout(user): shipping, express = [], [] if user is not None: for item in user.cart: if item.is_available: shipping.append(item) if item.express_selected: express.append(item) return shipping, express # BETTER! def checkout(user): shipping, express = [], [] if user is None: return shipping, express for item in user.cart: if not item.is_available: continue shipping.append(item) if item.express_selected: express.append(item) return shipping, expressBrian #3: Things you’re probably not using in Python 3 – but shouldVinko KodžomanSome of course items:f-stringsPathlib (side note. pytest tmp_path fixture creates temporary directories and files with PathLib)data classesSome I’m warming to:type hintingAnd those I’m really glad for the reminder of:enumerations from enum import Enum, auto class Monster(Enum): ZOMBIE = auto() WARRIOR = auto() BEAR = auto() print(Monster.ZOMBIE) # Monster.ZOMBIEbuilt in lru_cache: easy memoization with the functools.lru_cache decorator. @lru_cache(maxsize=512) def fib_memoization(number: int) -> int: ...extended iterable unpacking >>> head, *body, tail = range(5) >>> print(head, body, tail) 0 [1, 2, 3] 4 >>> py, filename, *cmds = "python3.7 script.py -n 5 -l 15".split() >>> cmds ['-n', '5', '-l', '15'] >>> first, _, third, *_ = range(10) >>> first, third (0, 2)Michael #4: The Python Arcade LibraryArcade is an easy-to-learn Python library for creating 2D video games. It is ideal for people learning to program, or developers that want to code a 2D game without learning a complex framework.Minesweeper games, hangman, platformer games in general.Check out Sample Games Made With The Arcade Library tooIncludes physics and other goodiesBased on OpenGLBrian #5: Teaching a kid to code with Pygame ZeroMatt LaymanScratch too far removed from coding.Using Mu to simplify coding interface.comes with a built in Python.Pygame Zero preinstalled“[Pygame Zero] is intended for use in education, so that teachers can teach basic programming without needing to explain the Pygame API or write an event loop.”Initial 29 line game taught:naming things and variablesmutability and fiddling with “constants” to see the effectfunctions and side effectsstate and timeinteractions and mouse eventsArticle also includes some tips on how to behave as the adult when working with kids and coding.Michael #6: Follow up on GIL / PEP 554Has the Python GIL been slain? by Anthony Shawmultithreading in CPython is easy, but it’s not truly concurrent, and multiprocessing is concurrent but has a significant overhead.Because Interpreter state contains the memory allocation arena, a collection of all pointers to Python objects (local and global), sub-interpreters in PEP 554 cannot access the global variables of other interpreters.the way to share objects between interpreters would be to serialize them and use a form of IPC (network, disk or shared memory). All options are fairly inefficientBut: PEP 574 proposes a new pickle protocol (v5) which has support for allowing memory buffers to be handled separately from the rest of the pickle stream.When? Pickle v5 and shared memory for multiprocessing will likely be Python 3.8 (October 2019) and sub-interpreters will be between 3.8 and 3.9.ExtrasBrian: PyCon 2019 videos are availableSo grateful for this. Already watched a couple, including Ant’s awesome talk about complexity and wily.pytest and hypothesis show up in the new Pragmatic Programmer book.Michael:100 Days of Web course is out!Effective PyCharm bookNew release of our Android and iOS apps.JokesMK → Waiter: Would you like coffee or tea? Programmer: Yes.
Sponsored by Datadog: pythonbytes.fm/datadogFolks this one is light on notes since we did it live. Enjoy the show!Special guestsEmily MorehouseSteve DowerTopicsBrian #1: pgcliMichael #2: PapermillEmily #3: Python Language SummitSteve #4: Python in Windows 10
Sponsored by DigitalOcean: pythonbytes.fm/digitaloceanBrian #1: Maintaining a Python Project when it’s not your jobPaul #2: Python in 1994youtube.com/watch?v=7NrPCsH0mBUBarry #3 Python leadership in 2019Michael #4: Textblobstackabuse.com
Sponsored by DigitalOcean: pythonbytes.fm/digitaloceanBrian #1: Solving Algorithmic Problems in Python with pytestAdam JohnsonHow to utilize pytest to set up quick test cases for coding challenges, like Project Euler or Advent of Code.Moving the specification and examples in the challenge description into test cases.Running the tests with a stub implementation and understanding the failure output.Gradually building up a working solution.Nice demo of how little code it takes to write quick test cases.Also a cool idea to use challenge sites and platforms as TDD/test first practice, as well as practice converting specifications into test cases.Michael #2: DepHell -- project management for Pythonvia @dreigelbWhy it is better than all other tools:Format agnostic. You can use DepHell with your favorite format: setup.py, requirements.txt, Pipfile, poetry. DepHell supports them all and much more.Use your favorite tool on any project. Want to install a poetry based project, but don't like poetry? Just say DepHell to convert project meta information into setup.py and install it with pip. Or directly work with the project from DepHell, because DepHell can do everything what you usually want to do with packages.DepHell doesn't try to replace your favorite tools. If you use poetry, you have to use poetry's file formats and commands. However, DepHell can be combined with any other tool or even combine all these tools together through formats converting. You can use DepHell, poetry and pip at the same time.Easily extendable. Pipfile should be just another one supported format for pip. However, pip is really old and big project with many bad decisions, so, PyPA team can't just add new features in pip without fear to broke everything. This is how pipenv has been created, but pipenv has inherited almost all problems of pip and isn't extendable too. DepHell has strong modularity and can be easily extended by new formats and commands.Developers friendly. We aren't going to place all our modules into [_internal](https://github.com/pypa/pip/tree/master/src/pip/_internal). Also, DepHell has big ecosystem with separated libraries to help you use some DepHell's parts without pain and big dependencies for your project.All-in-one-solution. DepHell can manage dependencies, virtual environments, tests, CLI tools, packages, generate configs, show licenses for dependencies, make security audit, get downloads statistic from pypi, search packages and much more. None of your tools can do it all.Smart dependency resolution. Sometimes pip and pipenv can't lock your dependencies. Try to execute pipenv install oslo.utils==1.4.0. Pipenv can't handle it, but DepHell can: dephell deps add --from=Pipfile oslo.utils==1.4.0 to add new dependency and dephell deps convert --from=Pipfile --to=Pipfile.lock to lock it.Asyncio based. DepHell doesn't support Python 2.7, and that allows us to use modern features to make network and filesystem requests as fast as possible.Multiple environments. You can have as many environments for project as you want. Separate sphinx dependencies from your main and dev environment. Other tools like pipenv and poetry don't support it.Brian #3 Python rant: from foo import is badMike CroucherI’m glad to see this post because I’m still seeing this practice a lot, even in tutorial blog posts!This is meaningless: result = sqrt(-1)Is it: math.sqrt(-1)? or numpy.sqrt(-1) or cmath.sqrt(-1)? or scipy? or sympy?Recommendation:Never do from x import *Use import mathor import numpy as npor even from scipy import sqrt Michael #4: DaskDask natively scales Python Have numpy, pandas, and scikit-learn code that needs to go faster?Run these on smart clusters of serversOr just on your laptopProcess more data than will fit into RAMSupported by… interesting to see proper support there.Matthew Rocklin was on Talk Python 207 to discussBrian #5: Animations with MatplotlibParul PandeyThe raindrop simulation is mesmerizing. Tutorial on using FuncAnimation to animate a sine wavealthough, I’m not sure what the x axis means during an animationAlso:live updates based on changing dataanimate turning a 3D plotusing celluloid package to animatesimple exampleanimating subplotschanging legend during animationMichael #6: PEP 554 -- Multiple Interpreters in the StdlibThis proposal introduces the stdlib interpreters module. The module will be provisional. It exposes the basic functionality of subinterpreters already provided by the C-API, along with new (basic) functionality for sharing data between interpreters.Sharing data centers around "channels", which are similar to queues and pipes.Examples and use-cases:Running isolated codeIn process, true parallelism Versioning of modules (?)Plugin systemsExtrasMichael:iOS Talk Python Training app is out: training.talkpython.fm/appsFind us at PyCon!Blessings terminal API (from Erik Rose, via Prayson Daniel)Jokesvia Topher ChungKnock knock.Race condition.Who's there?
Sponsored by Datadog: pythonbytes.fm/datadogSpecial guest: Kenneth ReitzBrian #1: inline_python (for rust)“I just made a Frankenstein's monster: Python code embedded directly in rustlang code. Should I kill it before it escapes the lab?” - Mara BosWriting some rust, and need a little Python?Maybe want to pop open a matplotlib window?This may be just the thing you need.see also:https://pypi.org/project/bash/Kenneth #2: Requests3: Under Way!Requests 2.x that you know and love is going into CVE-only mode (which it has been for a long time).Requests III is a new project which will bring async/await keywords to Requests.installable as requests3.Type-AnnotationsPython 3.6+Michael #3: 🔥 Pyflame: A Ptracing Profiler For PythonPyflame is a high performance profiling tool that generates flame graphs for Python.Pyflame is implemented in C++, and uses the Linux ptrace(2) system call to collect profiling information.It can take snapshots of the Python call stack without explicit instrumentationCapable of profiling embedded Python interpreters like uWSGI. Fully supports profiling multi-threaded Python programs.Why use it?Pyflame usually introduces significantly less overhead than the builtin profile (or cProfile) modules, and emits richer profiling data. The profiling overhead is low enough that you can use it to profile live processes in production.Brian #4: flit + srcCurrently a WIP PR.flit is easy. Given a module or a source package.flit init creates pyproject.toml and LICENSE files.commit those to gitflit build creates a wheelflit publish (builds and) publishes to whatever you have in your [.pypirc](https://docs.python.org/3/distutils/packageindex.html#the-pypirc-file)Changes in this PRThe flit project already has 2 types of projects.just a module, like foo.pya package (directory with __init__.py), like foo/__init__.pyThis would add a 3rd and 4th.just a module, but in src, like src/foo.pya package in src, like src/foo/__init__.pyMay be cracking open a can of worms, but I’m ok with that.Kenneth #5: $ pipx install pipenvMichael #6: cheat.shvia Jon BultmeyerNothing to install, but works on the CLI$ http cht.sh/python/sort+list$ http cht.sh/python/connect+to+databaseHas a CLI client too with a proper shellGet started with http cht.sh/python/:learnHas a funky stealth mode tooEditor integration VS Code & Vimcheat.sh uses selected community driven cheat sheet repositories and information sources, maintained by thousands of users, developers and authors all over the worldExtrasBrian:vi is good for beginners - fun read, for all you haters out there. But use vim, not vi.Better yet, IdeaVim for PyCharm or VSCodeVim for VS Code.nbstripout - command line tool to strip output from Jupyter Notebook files.We covered pyodide on episode 93, but here’s a cool article on itPyodide: Bringing the scientific Python stack to the browserMichael:PyCon AU CFPLIGO Blackhole collision follow up: https://www.youtube.com/watch?v=BXID4teFfDcvia Dave Kirby and Matthew Feickerthttps://github.com/kylebebak/questionnaire like Bullet but for windows toovia Sander TeunissenKenneth (optional):PyColorado CFPPyOhio CFPPyRemote!JokesDon’t know if I’ll do all of these, but I like them. 🙂 Brian and Kenneth, feel free to add yours if you have some!MK: Ubuntu users are apt to get these jokes.MK: How many programmers does it take to kill a cockroach? Two: one holds, the other installs Windows on it.MK: A programmer had a problem. He thought to himself, 'I know, I'll solve it with threads!'. has Now problems. two he(mildly offensive) KR: What’s the difference between a musician and a pizza? A pizza can feed a family of four.(In collaboration with Jonatan Skogsfors)Python used to be directed by the BDFL, Guido. Now it’s directed by a steering council, GUIDs[0:4].
Sponsored by DigitalOcean: pythonbytes.fm/digitaloceanSpecial guest: Cecil PhilipBrian #1: Python Used to Take Photo of Black HoleLots of people talking about this. The link I’m including is a quick write up by Mike Driscoll.From now on these conversations can happen:“So, what can you do with Python?”“Well, it was used to help produce the worlds first image of a black hole. Your particular problem probably isn’t as complicated as that, so Python should work fine.”Projects listed in the paper: “First M87 Event Horizon Telescope Results. III. Data Processing and Calibration”:Numpy (van der Walt et al. 2011)Scipy (Jones et al. 2001)Pandas (McKinney 2010)Jupyter (Kluyver et al. 2016)Matplotlib (Hunter 2007).Astropy (The Astropy Collaboration et al. 2013, 2018)Cecil #2: Wasmer - Python Library for executing WebAssembly binariesWebAssembly (Wasm) enables high level languages to target a portable format that runs in the webTons of languages compile down to Wasm but Wasmer enables the consumption of Wasm in pythonThis enables an interesting use case for using Wasm as a way to leverage code between languagesMichael #3: Cooked Inputcooked_input is a Python package for getting, cleaning, converting, and validating command line input.Name comes from input / raw_input (unvalidated) and cooked input (validated)Beginner’s can use the provided convenience classes to get simple inputs from the user.More complicated command line application (CLI) input can take advantage of cooked_input’s ability to create commands, menus and data tables.All sorts of cool validates and cleanersExamples cap_cleaner = ci.CapitalizationCleaner(style=ci.ALL_WORDS_CAP_STYLE) ci.get_string(prompt="What is your name?", cleaners=[cap_cleaner]) >>> ci.get_int(prompt="How old are you?", minimum=1) How old are you?: abc "abc" cannot be converted to an integer number How old are you?: 0 "0" too low (min_val=1) How old are you?: 67 67Brian #4: JetBrains and PyCharm officially collaborating with AnacondaPyCharm 2019.1.1 has some improvements for using Conda environments.Fixed various bugs related to creating Conda envs and installing packages into them.Special distribution of PyCharm: PyCharm for Anaconda with enhanced Anaconda support.I’m using PyCharm Pro with vim emulation this week to edit a notebook based presentation. I might run them in Jupyter, or just run it in PyCharm, but editing with all my normal keyboard shortcuts is awesome.Cecil #5: Building a Serverless IoT Solution with Python Azure Functions and SignalRInteresting blog post on using serverless, IoT, real-time messaging to create a live dashboardShows how to create a serverless function in Python to process IoT dataThere’s tons of DIY applications for using this technique at home The Dashboard is a static website using D3 for charting.Michael #6: multiprocessing.shared_memory — Provides shared memory for direct access across processesNew in Python 3.8This module provides a class, SharedMemory, for the allocation and management of shared memory to be accessed by one or more processes on a multicore or symmetric multiprocessor (SMP) machine.The ShareableList looks nice to use.ExtrasBrian:Getting ready for PyCon with STICKERS. Yeah, baby. Come see us at PyCon. I’ll also be bringing some copies of Python Testing with pytest, if anyone doesn’t already have a copy.Lots of interviews going on for Test & Code, and some will happen at PyCon.Cecil: Attendee Detector Workshop Talk Python training app on AndroidMichael:Guido van Rossum interviewed on MIT’s AI podcast via Tony Cappellini Visual Studio IntelliCode for VS & VS CodeShowing a Craigslist scammer who's boss using Python via Dan KosterJokesBrian: To understand recursion you must first understand recursion.Michael: A programmer was found dead in the shower. Next to their body was a bottle of shampoo with the instructions 'Lather, Rinse and Repeat'.
Sponsored by Datadog: pythonbytes.fm/datadogBrian #1: My How and Why: pyproject.toml & the 'src' Project StructureBrian Skinnpyproject.tomlbut with setuptools, instead of flit or poetrywith a src dirand tox and blackall the bits and pieces to make all of this workMichael #2: The Deadlock Empire: Slay dragons, master concurrency!A game to test your thread safety and skill!Deadlocks occur in code when two threads end up trying to enter two or more locks (RLocks please!)Consider lock_a and lock_bThread one enters lock_a and will soon enter lock_bThread two enters lock_b and will soon enter lock_aImagine transferring money between two accounts, each with a lock, and each thread does this in opposite order.Brian #3: Cog 3.0Ned Batchelder’s cog gets an update (last one was a few years ago).“Cog … finds snippets of Python in text files, executes them, and inserts the result back into the text. It’s good for adding a little bit of computational support into an otherwise static file.”Development moved from Bitbucket to GitHub. Travis and Appveyor CI.The biggest functional change is that errors during execution now get reasonable tracebacks that don’t require you to reverse-engineer how cog ran your code.mutmut mutation testing added. Cool.What I want to know more about is this statement: “…now I use it for making all my presentations”. Very cool idea.Michael #4: StackOverflow 2019 Developer Survey ResultsMore good news for PythonLots of focus on gender in this oneContributing to Open SourceAbout 65% of professional developers on Stack Overflow contribute to open source projects once a year or more. Involvement in open source varies with language. Developers who work with Rust, WebAssembly, and Elixir contribute to open source at the highest rates, while developers who work with VBA, C#, and SQL do so at about half those rates.Competence and ExperienceWe see evidence here among the most junior developers for impostor syndrome, pervasive patterns of self-doubt, insecurity, and fear of being exposed as a fraud. Among our respondents, men grew more confident much more quickly than gender minorities.Programming, Scripting, and Markup LanguagesPython edges out Java, second only to JavaScript (and two non-programming languages)DatabasesMySQL, Postgres, Microsoft SQL Server, SQLite, MongoDBMost Loved, Dreaded, and Wanted LanguagesLoved: Rust, PythonWanted: Python, JavaScriptDreaded: VBA, ObjectiveCMost Loved, Dreaded, and Wanted DatabasesLoved: PostgresWanted: MongoDBMost Popular Development EnvironmentsVS Code is crushing itHow Technologies Are Connected is just interestingBrian #5: Cuv’ner “A commanding view of your test-coverage"Coverage visualizations on the console.Michael #6: Mobile apps launchedThe tech (sadly only 50% Python)Xamarin, Mono, and C# on the device-sidePython, Pyramid, and MongoDB on the server-side90% code sharing or higherNative applicationsBuild the prototype myself on WindowsHired Giorgi via TopTalGet your own developer or get some freelancing work and support my app progress with my referral code: toptal.com/#we-annexed-perfect-engineers Dear mobile app developers: You have my sympathy!Try the app at training.talkpython.fm/apps Comes with 2 free courses for anyone who logs in.Android only at the moment but not for longExtrasBrian:Python Bytes Patreon page is up: patreon.com/pythonbytesMichael:PyCon BoothXKCD Plots in Matplotlib with examples via Tim HarrisonFira Code Retina and Font LigaturesThe EuroSciPy 2019 Conference will take place from September 2 to September 6 in Bilbao, SpainJokes“When your hammer is C++, everything begins to look like a thumb.”“Why don't jokes work in octal? Because 7 10 11” Over explained: Why is 6 afraid of 7. Cuz 7 8 9.Follow on: Why did 7 eat 9? He was trying to eat 3^2 meals.I've been using Vim for a long time now, mainly because I can't figure out how to exit.
Sponsored by DigitalOcean: pythonbytes.fm/digitaloceanBrian #1: pytest 4.4.0Lots of amazing new features here (at least for testing nerds)testpaths displayed in output, if used.pytest.ini setting that allows you to specify a list of directories or tests (relative to test rootdir) to test. (can speed up test collection).Lots of goodies for plugin writers.Internal changes to allow subtests to work with a new plugin, pytest-subtests.Just started playing with it, but I’m excited already. Planning on a full Test & Code episode after I play with it a bit more. # unittest example: class T(unittest.TestCase): def test_foo(self): for i in range(5): with self.subTest("custom message", i=i): self.assertEqual(i % 2, 0) # pytest example: def test(subtests): for i in range(5): with subtests.test(msg="custom message", i=i): assert i % 2 == 0Michael #2: requests-asyncasync-await support for requestsJust finished talking with Kenneth Reitz, native async coming to requests, but awhile offNice interm solutionRequires modern Python (3.6)Interesting Flask, Quart, Starlette, etc. framework wrapper for testingBrian #3: Reasons why PyPI should not be a serviceDustin Ingram’s article: PyPI as a Service“Layoffs at JavaScript package registry raise questions about fate of community resource” - The Register articleApparently PyPI gets requests for a private form of their service regularly, but there are problems with that.Currently a non-profit project under the PSF. That may be hard to maintain if they have a for-profit part.Donated services and infrastructure of more than $1M/year would be hard to replace.There are already other package repository options. Although there is probably room for others to compete.Currently run by volunteers for the most part. (<1 employee). Don’t think they would stick around to volunteer for a for-profit enterprise.conclusion: not impossible, but probably not worth it.Michael #4: Jupyter in the cloudSix easy ways to run your Jupyter Notebook in the cloud by Kevin Markhamsix services you can use to easily run your Jupyter notebook in the cloud. All of them have the following characteristics:They don't require you to install anything on your local machine.They are completely free (or they have a free plan).They give you access to the Jupyter Notebook environment (or a Jupyter-like environment).They allow you to import and export notebooks using the standard .ipynb file format.They support the Python language (and most support other languages as well).Binder is a service provided by the Binder Project, which is a member of the Project Jupyter open source ecosystem. It allows you to input the URL of any public Git repository, and it will open that repository within the native Jupyter Notebook interface.Kaggle is best known as a platform for data science competitions. However, they also provide a free service called Kernels that can be used independently of their competitions.Google Colaboratory, usually referred to as "Google Colab," is available to anyone with a Google account. As long as you are signed into Google, you can quickly get started by creating an empty notebook, uploading an existing notebook, or importing a notebook from any public GitHub repository.To get started with Azure Notebooks, you first sign in with a Microsoft or Outlook account (or create one). The next step is to create a "project", which is structured identically to a GitHub repository: it can contain one or more notebooks, Markdown files, datasets, and any other file you want to create or upload, and all of these can be organized into folders.CoCalc, short for "collaborative calculation", is an online workspace for computation in Python, R, Julia, and many other languages. It allows you to create and edit Jupyter Notebooks, Sage worksheets, and LaTeX documents.Datalore was created by JetBrains, the same company who makes PyCharm (a popular Python IDE). Getting started is as easy as creating an account, or logging in with a Google or JetBrains account. You can either create a new Datalore "workbook" or upload an existing Jupyter Notebook.Brian #5: Jupyter Notebook tutorialsThese are from DataquestJupyter Notebook for Beginners: A TutorialIncredibly gentle, concise, useful tutorial to get started quickly.Installation, creating, and running with server and browser.Discussion of .ipynb filesOverview of interface, cells, shortcuts, markdown.KernelsStarting with data. Importing appropriate libraries, loading data.Save and checkpointlooking at data, graphing/plotting dataSharing notebooks: exporting, using github and gists, nbviewer, Tutorial: Advanced Jupyter Notebooksshell commandsbasic magicsautosavingmatplotlib inlinedebugging in Jupyter (Brian: Gak! Maybe switch to PyCharm for debugging)using timeitrendering theml, latex, other languages in cells.logging, extensionscharts with seabornmacrosloading, importing and running external code and snippets.scripted execution, even on the command lineparametrization with env variablesstyling, hiding cells, working with databasesMichael #6: Unique sentinel values, identity checks, and when to use object() instead of NoneBy Trey HunnerIn Python (and in programming in general), you’ll need an object which can be uniquely identified. Sometimes this unique object represents a stop value or a skip value and sometimes it’s an initial value.Often this is None, but there are plenty of gotchas packed in there.Nice example of re-implementing min.Make sure to leverage is rather than == initial = object() # ... if minimum is not initial: return minimum # ...ExtrasBrianpytest-neoMichaelResponder courseAceJump for IntelliJ platforms (including PyCharm)Jokes
Sponsored by Datadog: pythonbytes.fm/datadogBrian #1: Deconstructing xkcd.com/1987/Brett CannonBreakdown of the infamous xkcd comic poking fun at the authors Python Environment on his computer.The interpreters listedHomebrew descriptionpython.org binariesA discussion of pip, easy_installThe paths and the $PATH and $PYTHONPATHActually quite an educational history lesson, and the abuse some people put their computers through.“So the next time someone decides to link to this comic as proof that Python has a problem, you can say that it's actually Randall's problem.”Michael #2: Python package as a CLI optionWanted to make this little app available via a CLI as a dedicated command. Really tired of python3 script.py or ./script.pyTurns out, pip and Python already solve this problem, if you structure your package correctlyThanks to everyone on Twitter!The trick turns out to be to have entrypoints in your package entry_points = { "console_scripts": ['bootstrap = bootstrap.bootstrap:main'] } ...This should even register it with pipx install package ;)Brian #3: pyrighta Microsoft static type checker for the Python language.“Pyright was created to address gaps in existing Python type checkers like mypy.”5x faster than mypymeant for large code baseswritten in TypeScript and runs within node.Michael #4: Refactoring Python Applications for SimplicityIf you can write and maintain clean, simple Python code, then it’ll save you lots of time in the long term. You can spend less time testing, finding bugs, and making changes when your code is well laid out and simple to follow.Is your code complex?Metrics for Measuring ComplexityLines of CodeCyclomatic complexity is the measure of how many independent code paths there are through your application.Maintainability IndexRefactoring: The technique of changing an application (either the code or the architecture) so that it behaves the same way on the outside, but internally has improved.Nice overview of tooling (PyCharm, VS Code plugins, etc)Anti-patterns and ways out of them (best part of the article IMO)Brian #5: FastAPIThanks Colin Sullivan for suggesting the topic“FastAPI framework, high performance, easy to learn, fast to code, ready for production”“Sales pitch / key features:Fast: Very high performance, on par with NodeJS and Go (thanks to Starlette and Pydantic). One of the fastest Python frameworks available.Fast to code: Increase the speed to develop features by about 200% to 300%. (estimated)Fewer bugs: Reduce about 40% of human (developer) induced errors. (estimated)Intuitive: Great editor support. Completion everywhere. Less time debugging.Easy: Designed to be easy to use and learn. Less time reading docs.Short: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.Robust: Get production-ready code. With automatic interactive documentation.Standards-based: Based on (and fully compatible with) the open standards for APIs: OpenAPI(previously known as Swagger) and JSON Schema.”uses:Starlette for the web parts.Pydantic for the data parts.document REST apis with bothSwaggerReDoclooks like quite a fun contender in the “put together a REST API quickly” set of solutions out there.Just the front page demo is quite informative. There’s also a tutorial that seems like it might be a crash course in API best practices.Michael #6: Bleach: stepping down as maintainerby Will Kahn-GreeneBleach is a Python library for sanitizing and linkifying text from untrusted sources for safe usage in HTML.A retrospective on OSS project maintenancePicked up maintenance of the project because I was familiar with itcurrent maintainer really wanted to step downMozilla was using it on a bunch of sitesI felt an obligation to make sure it didn't drop on the floor and I knew I could do it.Never really liked working on BleachHe did a bunch of work on a project I don't really use, but felt obligated to make sure it didn't fall on the floor, that has a pain-in-the-ass problem domain. Did that for 3+ years.Is [he] getting paid to work on it? Not really.Does [he] like working on it? No.Seems like [he] shouldn't be working on it anymore.ExtrasBriansleepsortMichael: PassboltPython 3.7.3 is now availablestackroboflow via Alexander AlloriJoke
Sponsored by DigitalOcean: pythonbytes.fm/digitaloceanBrian #1: Combining and separating dictionariesPEP 584 -- Add + and - operators to the built-in dict class.Steven D'ApranoDraft status, just created 1-March-2019d1 + d2 would merge d2 into d1like {**d1, **d2}or on two lines d = d1.copy() d.update(d2)of note, (d1 + d2) != (d2 + d1)Currently no subtraction equivalentGuido’s preference of + over |Related, Why operators are useful - also by GuidoMichael #2: Why I Avoid Slackby Matthew RocklinI avoid interacting on Slack, especially for technical conversations around open source software. Instead, I encourage colleagues to have technical and design conversations on GitHub, or some other system that is public, permanent, searchable, and cross-referenceable.Slack is fun but, internal real-time chat systems are, I think, bad for productivity generally, especially for public open source software maintenance.Prefer GitHub because I want toEngage collaborators that aren’t on our SlackRecord the conversation in case participants change in the future.Serve the silent majority of users who search the web for answers to their questions or bugs.Encourage thoughtful discourse. Because GitHub is a permanent record it forces people to think more before they write.Cross reference issues. Slack is siloed. It doesn’t allow people to cross reference people or conversations across SlacksBrian #3: Hunting for Memory Leaks in Python applicationsWai Chee YauConquering memory leaks and spikes in Python ML products at Zendesk.A quick tutorial of some useful memory toolsThe memory_profiler package and matplotlib to visualize memory spikes.Using muppy to heap dump at certain places in the code.objgraph to help memory profiling with object lineage.Some tips when memory leak/spike hunting:strive for quick feedbackrun memory intensive tasks in separate processesdebugger can add references to objectswatch out for packages that can be leakypandas? really?Michael #4: Give Me Back My Monolithby Craig KerstiensFeels like we’re starting to pass the peak of the hype cycle of microservicesWe’ve actually seen some migrations from micro-services back to a monolith.Here is a rundown of all the things that were simple that you now get to re-visitSetup went from intro chem to quantum mechanicsOnboarding a new engineering, at least for an initial environment would be done in the first day. As we ventured into micro-services onboarding time skyrocketedSo long for understanding our systemsBack when we had monolithic apps if you had an error you had a clear stacktrace to see where it originated from and could jump right in and debug. Now we have a service that talks to another service, that queues something on a message bus, that another service processes, and then we have an error.If we can’t debug them, maybe we can test themAll the trade-offs are for a good reason. Right?Brian #5: Famous Laws Of Software DevelopmentTim Sommer13 “laws” of software development, includingHofstadter’s Law: “It always takes longer than you expect, even when you take into account Hofstadter's Law.”Conway’s Law: “Any piece of software reflects the organizational structure that produced it.”The Peter Principle: “In a hierarchy, every employee tends to rise to his level of incompetence.”Ninety-ninety rule: “The first 90% of the code takes 10% of the time. The remaining 10% takes the other 90% of the time”Michael #6: Beer Garden PluginsA powerful plugin framework for converting your functions into composable, discoverable, production-ready services with minimal overhead.Beer Garden makes it easy to turn your functions into REST interfaces that are ready for production use, in a way that’s accessible to anyone that can write a function.Based on MongoDB, Rabbit MQ, & modern PythonNice docker-compose option tooExtrasMichael:Firefox SendEthical ads on Python Bytes (and Talk Python)Brian: T&C 69: The Pragmatic Programmer — Andy Huntnot up yet, but will be before this episode is releasedJokesFrom Derrick Chambers“What do you call it when a python programmer refuses to implement custom objects? self deprivation!Sorry, that joke was really classless.”via pyjokes: I had a problem so I thought I'd use Java. Now I have a ProblemFactory.
loading
Comments (10)

Raj

Thanks for the kubernetes example, and overall good episode

Mar 22nd
Reply

Mian A. Shah

ypf

Jan 28th
Reply

GreatBahram

As usual, perfect!

Jan 27th
Reply

Antonio Andrade

I think you missed to highlight all the nice work of realphlython and your podcasts, these are key stuffs for Python in 2018!

Dec 27th
Reply

Vignesh Anand Krishnan

The jokes are good but let brian do it. 😂

Dec 13th
Reply

GreatBahram

Congrats Python Bytes. This episode was really great 😎

Oct 27th
Reply

pyguy

Joel Grus talk can be found here: https://youtu.be/7jiPeIFXb6U

Oct 8th
Reply

Antonio Andrade

víbora means in Spanish: snake. umm, just thinking about Phyton

Aug 4th
Reply

GreatBahram

It's intetesting the title is flask but you guys spoke more about Django? kidding? hahaha please dont mess with us《Mico framework fans Thanks

Jun 28th
Reply

Antonio Andrade

nice, another super good Python postcast

May 20th
Reply
loading
Download from Google Play
Download from App Store