If all subsystems can communicate with all other subsystems, you lose the benefit of separating them at all. Make each subsystem meaningful by restricting communications. Steve McConnell Below is a tool for examining how modules in a Python package communicate with each other. Module Graph Each node in this graph is a module in the selected package. Edges indicate imports. Placing the mouse over a
なんか指名されたので、 C vs Python vs Ruby vs Haskell(無意味な処理deベンチマーク) このコードを Pythonic に書き直していきます。 ちなみに、 Python は 3.3 を使います。 まず、最初のコード n = 4000 a = [] count = 1 for x in range(n): a.append([]) for y in range(n): a[x].append(count) count += 1 list(map(lambda e: e.reverse(), a)) print(a[-1][-1]) time コマンドで実行速度測ったら 5.1sec でした。 さて、 Python はローカル変数とグローバル変数でアクセス速度が違います。(呼び出した関数の中などからグローバル変数を書き換えられる可能性はありますが、ローカル変数は外
CodernityDB pure python, fast, NoSQL database¶ CodernityDB is opensource, pure Python (no 3rd party dependency), fast (even 100 000 insert and more than 100 000 get operations per second, check Speed if you don’t believe in words), multi platform, schema-less, NoSQL database. You can also call it a more advanced key-value database, with multiple key-values indexes in the same engine (for sure it’s
2maru.com 2018 Copyright. All Rights Reserved. The Sponsored Listings displayed above are served automatically by a third party. Neither the service provider nor the domain owner maintain any relationship with the advertisers. In case of trademark issues please contact the domain owner directly (contact information can be found in whois). Privacy Policy
pythonの補完は、vimが標準で配布している物で事足りるかなーとか思ってたけど浅墓すぎた。 今日見つけた jedi-vim は良い。 davidhalter/jedi-vim - GitHub Using the jedi autocompletion library for VIM. https://github.com/davidhalter/jedi-vim 何が良いって精度が良い。そして標準配布の pythoncomplete がモジュールとそのモジュール内関数しか補完出来ないのに比べ、jedi は評価値を補完出来る。 そしてスゴイのが構文を仮実行しているのではなく、パースしている点。jedi というモジュールを使って、構文解析している。 davidhalter/jedi - GitHub Awesome autocompletion library for python. I
参考 1段ネストしたリストをflattenする方法 Making a flat list out of list of lists in Python - Stack Overflow 2段以上ネストしたリストをflattenする方法 Flatten (an irregular) list of lists in Python - Stack Overflow Right Foot In: More on python flatten 色々方法があるみたいなので書留め。 1段ネストしたリストをflattenするとは つまり、 l = [[1,2,3],[4,5,6], [7], [8,9]] を [1,2,3,4,5,6,7,8,9] にするということ。 reduceを使った方法 reduceを使ってリストを畳み込むことができる。 reduce(lambda x,y: x+y,l) 組込み
概要 pdb を利用してみる。 ドキュメント 公式ドキュメント「pdb — The Python Debugger」に概要が書いてある。 使い方 スクリプトを直接起動してデバッグする方法と、インタラクティブshell で起動する方法があるが、ここでは、スクリプトを起動してデバッグする方法で書く。 以下がデバッグするスクリプトのサンプル「even.py」。 自分の場合、スクリプトを直接デバッグすることがあまりなく、デバッグするのはライブラリとかをunittest経由でデバッグすることがが多いのでサンプルは unittest で書いている。 以下の例はクラス内の関数が偶数だけ返す所でバグがあり、奇数を返すようになっている。そんなに良い例ではないかも。 #!/usr/bin/env python # -*- coding: utf-8 -*- import unittest class Samp
Get More Done Type less and let Wing worry about the details. Use AI to write & redesign your code. Work interactively in the live Python runtime. Easily navigate code and documentation. Write Better Code Avoid common errors and find problems early with assistance from Wing's deep Python code analysis. Keep code clean with smart refactoring, code inspection, and reformatting.
ちょっと複雑なアルゴリズムをPythonで実装してみて、自分の予想以上にメモリを食ってしまったので何が原因なのかプロファイルしてみた。 辞書を大量に使ってはいけない 指摘されてみれば当たり前のことなんだけども、辞書はハッシュテーブルなのでメモリをたくさん使う。「グラフの頂点ごとに整数→整数のマッピングを持ちたいな」と思って、うっかり辞書を使ってしまったのだが、エントリー数が6個でも 1048バイト×頂点数 のメモリが吹っ飛んでいく。いくらハッシュのアクセスがO(1)だからといって、1048バイトmallocしてスラッシング起こしてんだったら全然安くない。エントリの個数とアクセス頻度によってはO(n)で線形探索したほうがよっぽどよい。 エントリーの個数が5件までならハッシュテーブルではないコンパクトな持ち方をするので280バイト。それでもでかい。 自作クラスのインスタンスも辞書を持っている
Django 1.4 がもうすぐリリースされます。気になる変更をあげてみます。 QuerySet.select_for_update() https://docs.djangoproject.com/en/dev/releases/1.4/#select-for-update-support1.3 以前のバージョンで Model に対して QuerySet を使って update をするには、QuerySet に対して QuerySet.objects.filter().update() としていました。更新する全てのモデルオブジェクトのインスタンスをループして、それぞれに対して Models.objects.save() を呼んでいると、最初にそのデータを取得した時点と save() を呼ぶ時点とで競合状態になる可能性があり、データを壊してしまう可能性があります。 QuerySet.s
今日、こんなことがありました。 -@gab_kmむ、なぜ標準モジュールのはずなのに ImportError になるのん…。 2012/10/05 09:16:32 事の次第は、今まで直接実行できていたあるPythonファイルが、何故かImportErrorで立ち上がらなくなっていたのです。 python hoge.py のように実行したときは上手くいきます。 私のつぶやきに、 @wonderful_panda さんと @methane さんがいろいろとアドバイスをくれました。 -@wonderful_panda@methane @gab_km Windowsでも、python hoge.py だと環境変数pathで決まる、hoge.pyだと拡張子pyに対するデフォルトアプリケーションで決まるという違いはあるので、別のpython.exeが選択される可能性はありますね。 2012/10/05
PyCon ZA 2012 presentation, not actually what the title says.
みんなのIoT/みんなのPythonの著者。二子玉近く160平米の庭付き一戸建てに嫁/息子/娘/わんこと暮らしてます。月間1000万PV/150万UUのWebサービス運営中。 免責事項 プライバシーポリシー Python 3を「使わない」理由というのが実はいくつかある。 たとえば対応しているフレームワークとかモジュールが少ないとか,そもそも2との互換性が崩れてるとか。対応モジュールやフレームワークはかなり増えてきたし,Python 3の情報もそこそこ出そろってきた。3.0がリリースされて4年弱経ち,この2点は大きく改善され,今ではあまり気にする必要はなくなっていると思う。 3を使わない理由が実はもう一つ「あった」。そしてこれは,個人的に最も気になっていたことなんだけど,Python 3は,2に比べてメモリ消費量が多くなっている。一番大きな原因は,str型(文字列型)がユニコードベースになっ
Python Tutor: Visualize Code and Get AI Help for Python, JavaScript, C, C++, and Java Python Tutor is designed to imitate what an instructor in an introductory programming class draws on the blackboard: Instructors use it as a teaching tool, and students use it to visually understand code examples and interactively debug their programming assignments. Quick links: Documentation and unsupported fea
Compile-time type checking Static typing makes it easier to find bugs with less debugging. Easier maintenance Type declarations act as machine-checked documentation. Static typing makes your code easier to understand and easier to modify without introducing bugs. Grow your programs from dynamic to static typing You can develop programs with dynamic typing and add static typing after your code has
pjson Like python -mjson.tool but with moar colors (and less conf) Usage ⚡ echo '{"json":"obj"}' | pjson { "json": "obj" } Looks Like This Image for the haters: Small retina display images are fucking huge. Example With Curl ⚡ curl https://github.com/igorgue.json | pjson Install Install pygments: ⚡ pip install pjson MFW I did This Project
Blog Search when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: ${entry.path} [in template "__entry.ftlh" at line 3, column 25] - Reached through: #include "__entry.ftlh" [in template "entry.ftlh" at
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く