Concurrency is not very intuitive. You need to train your brain to consider what happens when multiple processes execute a certain code block at the same time. There are several issues I often encounter: Failing to recognize potential concurrency issues: It's not uncommon for both beginner and seasoned developers to completely miss a potential concurrency problem. When this happens, and the concur
... in which we look at one or two ways to make life easier when working with Python regular expressions. tl;dr: You can compose verbose regular expressions using f-strings. Here's a real-world example – instead of this: 1pattern = r"((?:\(\s*)?[A-Z]*H\d+[a-z]*(?:\s*\+\s*[A-Z]*H\d+[a-z]*)*(?:\s*[\):+])?)(.*?)(?=(?:\(\s*)?[A-Z]*H\d+[a-z]*(?:\s*\+\s*[A-Z]*H\d+[a-z]*)*(?:\s*[\):+])?(?![^\w\s])|$)"
With each major Python release, all the attention goes to the new language features: the walrus operator, dictionary merging, pattern matching. There is also a lot of writing about asyncio and typing modules — they are developing rapidly and are obviously important for the core team. The rest of the standard library modules receive undeservedly little attention. I want to fix this and tell you abo
Python 3.11 までは、空文字でも64バイトのメモリを使用していました。(64bitプラットフォームの場合) Unicodeの内部表現のうち一番小さい PyASCIIObject 構造体が48バイトで、その構造体の後ろにASCII文字列が続きます。その文字列はNUL終端されているので、空文字列でも1バイト追加されて49バイトになります。 >>> sys.getsizeof("") 49 さらに小さいメモリブロックのアロケートをしているpymallocがメモリを(アライメントの関係で)16バイト単位で割り当てるので、49バイトのmallocでも64バイトが確保されてしまいます。 Python 3.12 からは、PyASCIIObject構造体から wchar_t* 表現をキャッシュするポインタが消え、40バイトになりました。それでASCIIで7文字までの文字列であれば48バイトに収ま
If you peruse the archives of language-summit blogs, you’ll find that one theme comes up again and again: the dream of Python without the GIL. Continuing this venerable tradition, Sam Gross kicked off the 2022 Language Summit by giving the attendees an update on nogil, a project that took the Python community by storm when it was first announced in October 2021. The GIL, or “Global Interpreter Loc
エムスリーエンジニアリンググループ AI・機械学習チームでソフトウェアエンジニアをしている中村(po3rin) です。検索とGoが好きです。 今回は社内でPyTerrierを採用して文書検索BatchをPythonで実装したので、PyTerrierの紹介とPyTerrierで日本語検索を実装する方法を紹介します(日本語でPyTerrierを扱う記事は多分初?)。 PyTerrierとは 弊社でのPyTerrier利用 PyTerrierで日本語検索 Phrase Queryの注意点 まとめ We're hiring !!! PyTerrierとは Terrierのロゴ PyTerrierは、Pythonでの情報検索実験のためのプラットフォームです。 JavaベースのTerrierを内部的に使用して、インデックス作成と検索操作を行うことができます。基本的なQuery RewritingやBM
Memray is a memory profiler for Python. It can track memory allocations in Python code, in native extension modules, and in the Python interpreter itself. It can generate several different types of reports to help you analyze the captured memory usage data. While commonly used as a CLI tool, it can also be used as a library to perform more fine-grained profiling tasks. Notable features: 🕵️♀️ Tra
Here are the most important updates on our favourite programming language. Even Better Error Messages When dealing with highly nested data structures (such like API responses) you might encounter a KeyError when trying to access undefined dictionary keys. Before Python 3.11 this has been particularly painful. Consider this code snippet: users = [ {'id': 1, 'name': 'Bas', 'social': {'twitter': '@ba
お断り この記事は『Software Design2022年3月号』の「第4章:電子署名のプロセスを体験 Pythonによる楕円曲線暗号の実装」の入稿記事を技術評論社のご好意で公開したものです。 元はLaTeXだったのをマークダウンに修正し、二つに分けています。 記事中のサンプルコードはサポートページからダウンロードできます。 はじめに この章では楕円曲線を用いた鍵共有や署名をPythonで実装します。実装するために必要な数学は随時解説します。 動作確認はPython 3.8.10で行いました。 コードは動作原理を理解するためのものであり、細かいエラー処理などはしていません。 プロダクト製品などで利用できるものではないことをご了承ください。 用語のおさらい 楕円曲線暗号の位置づけ まず最初に用語の確認をします。 「暗号」は複数の意味で使われます。 一つは「データを秘匿化するために、他人に読
Home recsys-python | Pythonによる推薦システム演習問題集 概要 recsys-pythonはPythonによる推薦システムの演習問題集です。推薦システムの基本である、評価履歴や評価値行列の扱いから、内容ベース推薦システム、近傍ベース協調フィルタリング、推薦システムの評価などに関する問題を取り揃えています。現時点では、13章構成で全163問用意しています。今後、内容を変更したり、問題を追加、削除したりすることもあります。 動機 言語処理100本ノックを参考にさせて頂き、推薦システム版の演習問題集を開発したいと思ったのがきっかけです。個人での学習に加え、大学での授業や研究室等でご活用いただければ幸いです。 到達目標 Pythonを学習しながら推薦システムの基本を修得できる。 評価履歴や評価値行列を扱いながらNumPyによる行列演算やベクトル演算を修得できる。 数式をP
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く