Skip to content

Instantly share code, notes, and snippets.

@blink1073
blink1073 / pymongo_greenlet.md
Created June 16, 2023 00:12
Async PyMongo with Greenlet

Async PyMongo with Greenlet

June 12, 2023

Proposal

Use greenletio to add asyncio support in PyMongo, with minimal changes to existing classes.

Background

The reason that Motor is not "truly asynchronous" is that we have blocking calls in PyMongo that do not enable cooperative multitasking. These include acquiring thread locks and socket i/o. Even if we were to use non-blocking versions of these, the event loop would still be blocked.

The previous proposal required rewriting the entirety of PyMongo to be asyncio-friendly, and gave a small performance hit for synchronous code, especially noticeable for small documents.

@blink1073
blink1073 / extension_types.py
Last active January 20, 2023 19:16
Pandas Extension Types for BSON
from __future__ import annotations
from bson import ObjectId, Decimal128, Binary
from pandas.api.extensions import ExtensionDtype, ExtensionArray, register_extension_dtype
from pandas._typing import type_t
import pyarrow as pa
from typing import Union, Any
import numpy as np
import pandas as pd
import numbers
"""Compare the dist file created by a migrated package to one created by the original."""
import argparse
import glob
import os
import shutil
import subprocess
import sys
import tarfile
import zipfile
@blink1073
blink1073 / LICENSE
Last active April 9, 2024 06:57
Wrap an Asynchronous Class
Copyright (c) 2022 Steven Silvester
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
@blink1073
blink1073 / meta.yml
Last active December 20, 2021 18:39
prototype conda recipe for pymongoarrow
{% set name = "pymongoarrow" %}
{% set version = "0.2.0.dev0" %}
package:
name: {{ name|lower }}
version: {{ version }}
source:
url: file:///home/runner/work/mongo-arrow/mongo-arrow/bindings/python/dist/pymongoarrow-{{ version }}.tar.gz
from subprocess import getoutput
import os
from datetime import datetime
from github_activity import generate_activity_md
import re
import sys
from ghapi.core import GhApi
name = sys.argv[-1]
os.chdir(name)
@blink1073
blink1073 / Backup Notes.md
Last active October 4, 2019 21:05
Jupyter Enterprise JEP (Draft)

When submitting an enhancement proposal, individuals will include the following information in their submission.

The problem that this enhancement addresses. If possible include code or anecdotes to describe this problem to readers.

A brief (1-2 sentences) overview of the enhancement you are proposing. If possible include hypothetical code sample to describe how the solution would work to readers.

A detailed explanation covering relevant algorithms, data structures, an API spec, and any other relevant technical information
A list of pros that this implementation has over other potential implementations.

A list of cons that this implementation has.

@blink1073
blink1073 / keybase.json
Created August 14, 2019 15:02
keybase.md
### Keybase proof
I hereby claim:
* I am blink1073 on github.
* I am blink1073 (https://keybase.io/blink1073) on keybase.
* I have a public key ASCDyw9ILX4MYwb0QEz0FoJCY3PcM49VZGetMmdcf3RsOAo
To claim this, I am signing this object:
@blink1073
blink1073 / plotting.ipynb
Created May 3, 2019 11:41
Octave Kernel Plotting
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.