Skip to content

Instantly share code, notes, and snippets.

View samuelcolvin's full-sized avatar

Samuel Colvin samuelcolvin

View GitHub Profile
import timeit
from pathlib import Path
import orjson
import pydantic_core
import ujson
import json
cases = [
('medium_response', Path('../jiter/benches/medium_response.json').read_bytes()),
import json
import random
import uuid
from datetime import date
import timeit
from typing import TypeVar, Generic
import pydantic_core
from pydantic import BaseModel
// this is lightly better than simple debounce as:
// 1. it kicks of a new search immediately
// 2. it waits for a server re
function debounceLoadOptions(searchUrl: string) {
let running = false
let runNext: [string, OptionsCallback] | null = null
const run = (inputValue: string, callback: OptionsCallback, force: boolean) => {
if (running && !force) {
runNext = [inputValue, callback]

Senior Frontend Developer at Pydantic

Opportunity to join Pydantic! We are looking to hire someone to lead our frontend development.

We want to hire a senior engineer who is as experienced with TypeScript, React and UI/UX as we are with Python, Rust and API design.

No recruiters or agencies please, any contact from recruiters will be marked as spam.

About Pydantic

samuelcolvin /
Last active March 2, 2024 16:04
OpenAI powered AI CLI in just a few lines of code - moved to
#!/usr/bin/env python3
import os
from datetime import datetime, timezone
from pathlib import Path
from prompt_toolkit import PromptSession
from prompt_toolkit.history import FileHistory
import openai
from rich.console import Console
from rich.markdown import Markdown
samuelcolvin /
Created July 13, 2023 16:57
Pydantic parsing JSON and validating URLs vs. pure pyton
import timeit
import json
from urllib.parse import urlparse
import requests
from pydantic import TypeAdapter, HttpUrl
reps = 7
number = 100
r = requests.get('')
import polars as pl
ds = pl.read_parquet('page_views.parquet').sort('ts')
path_counts = (
ds.with_columns(pl.col('path').str.replace(r'^/(latest|dev-v\d|\d\.\d+)', ''))
pydantic-core: 01fdec6d2242fdf7205663d566be5ba990d1d459 - the custom-dataclass-validator branch
and pydantic: 519800fa5167a57681ba3b202503751aa0f17347 - the dataclasses-v2 branch
from typing import TypeVar
import pytest
from pydantic import BaseModel, ValidationError
samuelcolvin /
Last active March 13, 2024 03:13
An incomplete list of people in the Python community to follow on Twitter and Mastodon.

Python People

(Updated 2022-11-16 with suggestions from comments below, Twitter and Mastodon)

An incomplete list of people in the Python community to follow on Twitter and Mastodon.

With the risk that Twitter dies, I'd be sad to lose links to interesting people in the community, hence this list.

I would love you to comment below with links to people I've missed.

samuelcolvin /
Last active May 10, 2023 17:45
auto-generate assert statements in pytest
License: MIT
Copyright (c) 2022 Samuel Colvin.
## Usage
Once installed just add