Date: Mon, 18 May 2020 08:00:00 -0400
<div class="wp-block-jetpack-markdown"><h3>Summary</h3> <p>One of the most common causes of bugs is incorrect data being passed throughout your program. Pydantic is a library that provides runtime checking and validation of the information that you rely on in your code. In this episode Samuel Colvin explains why he created it, the interesting and useful ways that it can be used, and how to integrate it into your own projects. If you are tired of unhelpful errors due to bad data then listen now and try it out today.</p> <h3>Announcements</h3> <ul> <li>Hello and welcome to Podcast.__init__, the podcast about Python and the people who make it great.</li> <li>When you’re ready to launch your next app or want to try a project you hear about on the show, you’ll need somewhere to deploy it, so take a look at our friends over at Linode. With 200 Gbit/s private networking, node balancers, a 40 Gbit/s public network, fast object storage, and a brand new managed Kubernetes platform, all controlled by a convenient API you’ve got everything you need to scale up. And for your tasks that need fast computation, such as training machine learning models, they’ve got dedicated CPU and GPU instances. Go to <a href="https://www.pythonpodcast.com/linode?utm_source=rss&utm_medium=rss">pythonpodcast.com/linode</a> to get a $20 credit and launch a new server in under a minute. And don’t forget to thank them for their continued support of this show!</li> <li>You listen to this show because you love Python and want to keep your skills up to date. Machine learning is finding its way into every aspect of software engineering. Springboard has partnered with us to help you take the next step in your career by offering a scholarship to their Machine Learning Engineering career track program. In this online, project-based course every student is paired with a Machine Learning expert who provides unlimited 1:1 mentorship support throughout the program via video conferences. You’ll build up your portfolio of machine learning projects and gain hands-on experience in writing machine learning algorithms, deploying models into production, and managing the lifecycle of a deep learning prototype. Springboard offers a job guarantee, meaning that you don’t have to pay for the program until you get a job in the space. Podcast.__init__ is exclusively offering listeners 20 scholarships of $500 to eligible applicants. It only takes 10 minutes and there’s no obligation. Go to <a href="https://www.pythonpodcast.com/springboard?utm_source=rss&utm_medium=rss">pythonpodcast.com/springboard</a> and apply today! Make sure to use the code AISPRINGBOARD when you enroll.</li> <li>Your host as usual is Tobias Macey and today I’m interviewing Samuel Colvin about Pydantic, a library for enforcing type hints at runtime</li> </ul> <h3>Interview</h3> <ul> <li>Introductions</li> <li>How did you get introduced to Python?</li> <li>Can you start by describing what Pydantic is and what motivated you to create it?</li> <li>What are the main use cases that benefit from Pydantic?</li> <li>There are a number of libraries in the Python ecosystem to handle various conventions or "best practices" for settings management. How does pydantic fit in that category and why might someone choose to use it over the other options?</li> <li>There are also a number of libraries for defining data schemas or validation such as Marshmallow and Cerberus. How does Pydantic compare to the available options for those cases? <ul> <li>What are some of the challenges, whether technical or conceptual, that you face in building a library to address both of these areas?</li> </ul> </li> <li>The 3.7 release of Python added built in support for dataclasses as a means of building containers for data with type validation. What are the tradeoffs of pydantic vs the built in dataclass functionality?</li> <li>How much overhead does pydantic add for doing runtime validation of the modelled data?</li> <li>In the documentation there is a nuanced point that you make about parsing vs validation and your choices as to what to support in pydantic. Why is that a necessary distinction to make? <ul> <li>What are the limitations in terms of usage that you are accepting by choosing to allow for implicit conversion or potentially silent loss of precision in the parsed data?</li> <li>What are the benefits of punting on the strict validation of data out of the box?</li> </ul> </li> <li>What has been your design philosophy for constructing the user facing API?</li> <li>How is Pydantic implemented and how has the overall architecture evolved since you first began working on it? <ul> <li>What have you found to be the most challenging aspects of building a library for managing the consistency of data structures in a dynamic language? <ul> <li>What are some of the strengths and weaknesses of Python’s type system?</li> </ul> </li> </ul> </li> <li>What is the workflow for a developer who is using Pydantic in their code? <ul> <li>What are some of the pitfalls or edge cases that they might run into?</li> </ul> </li> <li>What is involved in integrating with other libraries/frameworks such as Django for web development or Dagster for building data pipelines?</li> <li>What are some of the more advanced capabilities or use cases of Pydantic that are less obvious?</li> <li>What are some of the features or capabilities of Pydantic that are often overlooked which you think should be used more frequently?</li> <li>What are some of the most interesting, innovative, or unexpected ways that you have seen Pydantic used?</li> <li>What are some of the most interesting, challenging, or unexpected lessons that you have learned through your work on or with Pydantic?</li> <li>When is Pydantic the wrong choice?</li> <li>What do you have planned for the future of the project?</li> </ul> <h3>Keep In Touch</h3> <ul> <li><a href="https://github.com/samuelcolvin?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">samuelcolvin</a> on GitHub</li> <li><a href="https://scolvin.com/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Website</a></li> <li><a href="https://www.linkedin.com/in/samuel-colvin-27531523/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">LinkedIn</a></li> <li><a href="https://twitter.com/samuel_colvin?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">@samuel_colvin</a> on Twitter</li> </ul> <h3>Picks</h3> <ul> <li>Tobias <ul> <li><a href="https://www.jollylama.com/product-category/juggling-sticks/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Devil Sticks</a></li> </ul> </li> <li>Samuel <ul> <li><a href="https://wwnorton.com/books/flash-boys/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Flash Boys</a> by Michael Lewis</li> <li><a href="https://algorithmstoliveby.com/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Algorithms To Live By</a> by Brian Christian and Tom Griffiths</li> <li><a href="https://ngrok.com/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">NGrok.com</a></li> </ul> </li> </ul> <h3>Closing Announcements</h3> <ul> <li>Thank you for listening! Don’t forget to check out our other show, the <a href="https://feeds.fireside.fm/pythonpodcast/rss">Data Engineering Podcast</a> for the latest on modern data management.</li> <li>Visit the <a href="https://www.pythonpodcast.com?utm_source=rss&utm_medium=rss">site</a> to subscribe to the show, sign up for the mailing list, and read the show notes.</li> <li>If you’ve learned something or tried out a project from the show then tell us about it! Email <a href="mailto:hosts@podcastinit.com">hosts@podcastinit.com</a>) with your story.</li> <li>To help other people find the show please leave a review on <a href="https://itunes.apple.com/us/podcast/podcast.-init/id981834425?mt=2&uo=6&at=&ct=&utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">iTunes</a> and tell your friends and co-workers</li> <li>Join the community in the new Zulip chat workspace at <a href="https://www.pythonpodcast.com/chat?utm_source=rss&utm_medium=rss">pythonpodcast.com/chat</a></li> </ul> <h3>Links</h3> <ul> <li><a href="https://pydantic-docs.helpmanual.io/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Pydantic</a></li> <li><a href="https://www.mathworks.com/products/matlab.html?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Matlab</a></li> <li><a href="https://en.wikipedia.org/wiki/C_Sharp_(programming_language)?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">C#</a></li> <li><a href="https://fastapi.tiangolo.com/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">FastAPI</a> <ul> <li><a href="https://www.pythonpodcast.com/fastapi-web-application-framework-episode-259/?utm_source=rss&utm_medium=rss">Podcast Episode</a></li> </ul> </li> <li><a href="https://marshmallow.readthedocs.io/en/stable/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Marshmallow</a> <ul> <li><a href="https://www.pythonpodcast.com/marshmallow-data-validation-episode-200/?utm_source=rss&utm_medium=rss">Podcast Episode</a></li> </ul> </li> <li><a href="https://docs.python-cerberus.org/en/stable/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Cerberus</a></li> <li><a href="https://12factor.net/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">12 Factor App</a></li> <li><a href="https://www.djangoproject.com/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Django</a></li> <li><a href="https://www.python.org/dev/peps/pep-0484/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Python Type Hints</a></li> <li><a href="https://cython.org/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Cython</a> <ul> <li><a href="https://www.pythonpodcast.com/episode-45-cython-with-craig-citro-and-robert-bradshaw/?utm_source=rss&utm_medium=rss">Podcast Episode</a></li> </ul> </li> <li><a href="http://mypy-lang.org/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">MyPy</a> <ul> <li><a href="https://www.pythonpodcast.com/episode-65-mypy-with-david-fisher-and-greg-price/?utm_source=rss&utm_medium=rss">Podcast Episode</a></li> </ul> </li> <li><a href="https://en.wikipedia.org/wiki/Duck_typing?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Duck Typing</a></li> <li><a href="https://www.haskell.org/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Haskell</a></li> <li><a href="https://en.wikipedia.org/wiki/Kind_(type_theory)?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Higher Order Types</a></li> <li><a href="https://plugins.jetbrains.com/plugin/12861-pydantic?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">PyCharm Pydantic Plugin</a></li> <li><a href="https://www.django-rest-framework.org/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Django Rest Framework</a></li> <li><a href="http://avro.apache.org/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Avro</a></li> <li><a href="https://parquet.apache.org/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Parquet</a></li> <li><a href="https://github.com/dagster-io/dagster/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Dagster</a> <ul> <li><a href="https://www.dataengineeringpodcast.com/dagster-data-applications-episode-104/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Data Engineering Podcast Episode</a></li> </ul> </li> <li><a href="https://www.starlette.io/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Starlette</a></li> <li><a href="https://flask.palletsprojects.com/en/1.1.x/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Flask</a></li> <li><a href="https://uber.github.io/ludwig/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Ludwig</a></li> <li><a href="http://deeppavlov.ai/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Deep Pavlov</a></li> <li><a href="https://fastmri.org/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Fast MRI</a></li> <li><a href="https://reagent.ai/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Reagent</a></li> <li><a href="http://rags.github.io/pynt/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Pynt</a></li> <li><a href="https://medium.com/@johnmark/why-open-source-failed-6cae5d6a9f6?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Open Source Has Failed</a> article</li> </ul> <p>The intro and outro music is from Requiem for a Fish <a href="http://freemusicarchive.org/music/The_Freak_Fandango_Orchestra/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">The Freak Fandango Orchestra</a> / <a href="http://creativecommons.org/licenses/by-sa/3.0/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">CC BY-SA</a></p> </div> <img alt="" height="0" src="https://analytics.boundlessnotions.com/piwik.php?idsite=1&rec=1&url=https%3A%2F%2Fwww.pythonpodcast.com%2Fpydantic-data-validation-episode-263%2F&action_name=Easy+Data+Validation+For+Your+Python+Projects+With+Pydantic+-+Episode+263&urlref=https%3A%2F%2Fwww.pythonpodcast.com%2Ffeed%2F&utm_source=rss&utm_medium=rss" style="border: 0; width: 0; height: 0;" width="0" />