Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
#include <assert.h> | |
#include <stdarg.h> | |
#include <stdbool.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <unistd.h> | |
enum type { | |
NIL, |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
package main | |
import ( | |
"fmt" | |
) | |
type Node struct { | |
Value int | |
} |
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs
import struct | |
import SocketServer | |
from base64 import b64encode | |
from hashlib import sha1 | |
from mimetools import Message | |
from StringIO import StringIO | |
class WebSocketsHandler(SocketServer.StreamRequestHandler): | |
magic = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11' |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset=utf-8> | |
<title>WebSocket test</title> | |
</head> | |
<body> | |
<script> | |
if (window.MozWebSocket) { | |
window.WebSocket = window.MozWebSocket; |
/* | |
* An implementation of C11 stdatomic.h directly borrowed from FreeBSD | |
* (original copyright follows), with minor modifications for | |
* portability to other systems. Works for recent Clang (that | |
* implement the feature c_atomic) and GCC 4.7+; includes | |
* compatibility for GCC below 4.7 but I wouldn't recommend it. | |
* | |
* Caveats and limitations: | |
* - Only the ``_Atomic parentheses'' notation is implemented, while | |
* the ``_Atomic space'' one is not. |
# coding=utf-8 | |
""" | |
LICENSE http://www.apache.org/licenses/LICENSE-2.0 | |
""" | |
import datetime | |
import sys | |
import time | |
import threading | |
import traceback | |
import SocketServer |
/* | |
******************************************************************************* | |
* The C++ Integer To String Conversion Benchmark * | |
* * | |
* Version: 2.718-20131130 * | |
* * | |
* This benchmark is based on the solutions provided in the following * | |
* stackoverflow question: * | |
* * | |
* http://stackoverflow.com/q/4351371 (Date: 20101204) * |