Skip to content

Instantly share code, notes, and snippets.

View lvxejay's full-sized avatar

Jared Webber lvxejay

View GitHub Profile
@lvxejay
lvxejay / mutable_namedtuple_comparison.py
Created October 9, 2020 22:20 — forked from grantjenks/mutable_namedtuple_comparison.py
Performance Comparison of namedtuple, namedlist, and recordclass
import sys
class Record(object):
__slots__ = ()
def __init__(self, *args):
assert len(self.__slots__) == len(args)
for field, value in zip(self.__slots__, args):
setattr(self, field, value)
@lvxejay
lvxejay / zmq_raw_bench.py
Last active July 22, 2021 17:41
ZMQ Benchmarking
#! /usr/bin/env/python3
# --------------------------------------------------------------------------- HEADER --#
"""
:author:
Jared Webber
:description:
Somewhat crude ZMQ Performance Benchmark and Tests
@lvxejay
lvxejay / 00README.rst
Created June 26, 2019 04:14 — forked from GaelVaroquaux/00README.rst
Copy-less bindings of C-generated arrays with Cython

Cython example of exposing C-computed arrays in Python without data copies

The goal of this example is to show how an existing C codebase for numerical computing (here c_code.c) can be wrapped in Cython to be exposed in Python.

The meat of the example is that the data is allocated in C, but exposed in Python without a copy using the PyArray_SimpleNewFromData numpy

// https://stackoverflow.com/questions/10750057/how-to-print-out-the-contents-of-a-vector/11335634#11335634
#include <iostream>
#include <algorithm> // for copy
#include <iterator> // for ostream_iterator
#include <vector>
int main() {
/* Set up vector to hold chars a-z */
std::vector<char> path;