- 一对象的引用计数机制
- 二垃圾回收机制
- 三内存池机制
Python内部使用引用计数,来保持追踪内存中的对象,所有对象都有引用计数。
body { | |
font-family: Helvetica, arial, sans-serif; | |
font-size: 14px; | |
line-height: 1.6; | |
padding-top: 10px; | |
padding-bottom: 10px; | |
background-color: white; | |
padding: 30px; } | |
body > *:first-child { |
#!/bin/bash | |
# Swarm mode using Docker Machine | |
managers=3 | |
workers=3 | |
# 创建管理节点虚拟机 | |
echo "======> Creating $managers manager machines ..."; | |
for node in $(seq 1 $managers); |
function hexToRgb (hex) { | |
var rgb = []; | |
hex = hex.substr(1); //去除前缀 # 号 | |
if (hex.length === 3) { // 处理 "#abc" 成 "#aabbcc" | |
hex = hex.replace(/(.)/g, '$1$1'); | |
} | |
hex.replace(/../g, function(color){ |
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
# Python的线程池实现 | |
import Queue | |
import threading | |
import sys | |
import time | |
#coding: utf8 | |
import hashlib | |
import pickle | |
import time | |
CACHE = {} | |
def is_obsolete(entry, duration): | |
return time.time() - entry['time'] > duration |
# author: the5fire.com | |
import re | |
import socket | |
from collections import namedtuple | |
RE_URL = re.compile(r'http://(.*)') | |
RE_CONTENT_LENGTH = re.compile(b'.*Content-Length: (\d+)') | |
EOF = '\r\n\r\n' | |
Response = namedtuple('Response', ['header', 'body']) |
# -*- coding:utf-8 -*- | |
# class ListNode: | |
# def __init__(self, x): | |
# self.val = x | |
# self.next = None | |
class Solution: | |
# 返回ListNode | |
def ReverseList(self, pHead): | |
# write code here | |
if pHead is None or pHead.next is None: |
from collections import OrderedDict | |
od = OrderedDict(zip('foo', 'bar')) | |
# 方法1 | |
od.keys()[-1] # 仅适用于2 | |
od.values()[-1] | |
od.items()[-1] | |
list(od.items())[-1] # 兼容 3.x |