Skip to content

Instantly share code, notes, and snippets.

View richardkiss's full-sized avatar

Richard Kiss richardkiss

View GitHub Profile
@richardkiss
richardkiss / deal.py
Created April 25, 2023 17:44
Hand permutations to index and vice versa
from math import comb
from typing import List
Hand = List[int]
def hand_from_index(index: int, deck_indices: List[int], hand_size: int) -> Hand:
hand = []
deck_size = len(deck_indices)
@richardkiss
richardkiss / chialisp_distribution.md
Created July 13, 2023 01:09
Overview of wheels for chialisp distribution

The load_clvm method has been duplicated in multiple places, each version with slightly different semantics and bugs. We present here a set of tiny python wheels that solve many problems with chialisp contracts including:

  • distribution of libraries
  • distribution of compiled .hex files
  • automatic dynamic builds in development mode
  • dependency analysis (on library include files)

runtime_builder

@richardkiss
richardkiss / ffi.py
Last active December 17, 2023 08:02
Using ctypes in python to call a mojo function (mojo 0.6)
from ctypes import CFUNCTYPE, c_int
Ft = CFUNCTYPE(c_int, c_int, c_int)
def entry_point(ptr_to_function):
function_pointer = Ft(ptr_to_function)
result = function_pointer(5000, 2)
return result
@richardkiss
richardkiss / chia-db.md
Created December 21, 2023 21:06
Benchmarking `chia-blockchain` DB

This is a report on the chia-blockchain sqlite3 DB. The concern is that some operations are slow, and get slower over time. The symptom is the conversion from v1 of the DB to v2 never finishes and seems to get slower asymptotically as time goes on. This may affect performance during regular day-to-day operation, since DB conversion is not wholy different from DB operations performed on a day-to-day basis.

Summary

There are six tables and eight indices.