Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Private dispatch table not checked

オープン
#437 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
tooling

調査の方向性

cloudpickle.CloudPickler から始め、リンクされたリファレンスで説明されている標準の pickle.Pickler の動作と、その dispatch_table がどのように参照されるかを比較してください。提供された CustomClass の再現コードを実行し、private dispatch table によってグローバルな pickle の動作を変更せずに c3.x が 1 に変わることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

enhancement

I'm attempting to register a custom reducer with cloudpickle. In my use case, I need multiple CloudPickler's to serialize an object with different behavior, so I can't override the class-level global dispatch table.

To demonstrate, assume I have the following class:

class CustomClass:
    def __init__(self, *args):
        self.x = len(args)

c = CustomClass()

I can define a custom reducer and register it with a private dispatch table:

def custom_reducer(obj):
    return CustomClass, (0,)

io_buffer = io.BytesIO()
custom_pickler = pickle.Pickler(io_buffer)
custom_pickler.dispatch_table = {CustomClass: custom_reducer}
custom_pickler.dump(c)

io_buffer.seek(0)
c1 = pickle.load(io_buffer)
assert c1.x == 1

I can also prove that this doesn't affect the global dispatch table:

c2 = pickle.loads(pickle.dumps(c))
assert c2.x == 0

Unfortunately, when I try the same behavior with cloudpickle, it doesn't respect the private dispatch table:

io_buffer = io.BytesIO()
custom_pickler = cloudpickle.CloudPickler(io_buffer)
custom_pickler.dispatch_table = {CustomClass: custom_reducer}
custom_pickler.dump(c)

io_buffer.seek(0)
c3 = cloudpickle.load(io_buffer)
assert c3.x == 1 # assertion fails becase c3.x == 0

(reference to how this was implemented in pickle)

主要言語
Python
スター
1.9k
フォーク
197
平均マージ
1日 10時間
マージ済み PR(30日)
1

環境構築

このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

cloudpipe/cloudpickle のほかの issue

cloudpipe/cloudpickle の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。