- Uncompressed JSON size: 13829
- Uncompressed CBOR size: 7816
- GZIP JSON size: 4215
- GZIP CBOR size: 1192
- JSON took 0.412476 seconds to execute 1000 times.
- CBOR took 0.466668 seconds to execute 1000 times.
- Deserialize JSON took 0.474627 seconds to execute 1000 times.
- Deserialize CBOR took 0.686742 seconds to execute 1000 times.
- JSON + GZIP took 2.089109 seconds to execute 1000 times.
- CBOR + GZIP took 0.857445 seconds to execute 1000 times.
from multiprocessing import Pool | |
from time import time | |
data = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve"] | |
progression = [1,2,4,6,12] | |
def do(name): | |
start = time() |
from functools import total_ordering | |
i = 0 | |
weights = {} | |
for alpha in 'abcdefghijklmnopqrstuvwxyz': | |
i += 1 | |
weights[alpha] = i | |
@total_ordering | |
class weighted_word(object): |
import base64 | |
import pickle | |
from random import randrange | |
from sys import getsizeof | |
from time import perf_counter_ns | |
from icecream import ic | |
lol = [[randrange(10) for i in range(randrange(10))] for i in range(10000)] |
CONST_START = 0x0 | |
CONST1 = 0xCC9E2D51 | |
CONST2 = 0x1B873593 | |
def hash_word(text: str): | |
""" | |
32bit murmur3 hash. | |
Written by Patrick Shechet | |
Based on pymmh3 by Fredrik Kihlander and Swapnil Gusani: https://github.com/wc-duck/pymmh3/blob/master/pymmh3.py |
""" | |
This example uses datetime, but the method applies generally to classes with chainable methods | |
(i.e. classes with methods that return an instance of the same class.) | |
Subclassing such classes quickly becomes annoying, because the methods return an instance of the original class, not the subclass. | |
With this method, you can still call the methods of the wrapped datetime, but you get back an instance of WrappedDateTime. | |
Also preserves comparisons with datetime.datetime. | |
""" |
import typing as t | |
from functools import partial | |
from inspect import getsource | |
class ConfigError(ValueError): | |
... | |
def get_func_name(func: t.Callable) -> str: |
BSD 2-Clause License | |
Copyright (c) 2021, Patrick Shechet | |
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. |
Below is an instruction that describes a task. Write a response that appropriately completes the request
Please write a function called sumTable that accepts a query selector for an HTML table. The function should take a query selector string as a parameter. sumTable should loop through the columns of the table adding all the cells in each column if they are numbers (ignore cells that do not contain a number.) It should then add a row to the table containing the the sum of each column.
The function must be javascript.
Below is an instruction that describes a task. Write a response that appropriately completes the request
Please write a detailed list of files, and the functions those files should contain, for a python application. The application is a simple note taking app. The application should use a sqlite3 back-end and must use the falcon web framework.
- The user should be able to create a new note by providing a title and a body.
- The user should be able to view all their notes.
- The user should be able to view a specific note by providing its ID.