Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
" | incsearch.vim | / ? g/ n N * # g* g# | {{{ | |
let g:incsearch#auto_nohlsearch = 1 | |
map / <Plug>(incsearch-forward) | |
map ? <Plug>(incsearch-backward) | |
map g/ <Plug>(incsearch-stay) | |
map n <Plug>(incsearch-nohl-n) | |
map N <Plug>(incsearch-nohl-N) | |
map * <Plug>(incsearch-nohl-*) | |
map # <Plug>(incsearch-nohl-#) |
# Terminal | |
set -g default-terminal "screen-256color" | |
# No delay for escape key press | |
set -sg escape-time 0 | |
# This tmux statusbar config was created by tmuxline.vim | |
# on Wed, 25 Feb 2015 | |
set -g status-bg "colour238" | |
set -g message-command-fg "colour188" |
class FirstModel(models.Model): | |
pass | |
class SecondModel(models.Model): | |
pass | |
class BaseModel(models.Model): | |
content_type = models.ForeignKey(ContentType) |
#!/usr/bin/python | |
from __future__ import print_function | |
import pathlib | |
import argparse | |
import os | |
from neovim import attach |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
As of version 3.3, python includes the very promising concurrent.futures
module, with elegant context managers for running tasks concurrently. Thanks to the simple and consistent interface you can use both threads and processes with minimal effort.
For most CPU bound tasks - anything that is heavy number crunching - you want your program to use all the CPUs in your PC. The simplest way to get a CPU bound task to run in parallel is to use the ProcessPoolExecutor, which will create enough sub-processes to keep all your CPUs busy.
We use the context manager thusly:
with concurrent.futures.ProcessPoolExecutor() as executor:
Во-первых, это моё мнение, и я его никому не навязываю. Во-вторых, список не обязательно исчерпывающий. В-третьих, он ориентирован на определённую "философию", которая тоже не является исчерпывающей или абсолютно правильной. Поэтому, если Вам эти рекомендации не подходят -- не следуйте им.
Философия такова. Для того чтобы осмысленно программировать на начальном этапе не нужно знать Computer Science, теорию алгоритмов и сложности вычислений или детально разбираться в устройстве и работе компьютера. Достаточно хорошо делать две вещи: