VNT: Improve use of `typejoin` in VarNamedTuple

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

メンテナーはふだん 2 日以内に返信

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
julia
領域
performance

調査の方向性

まず VarNamedTuple と PartialArray の実装を見つけ、値が代入されたときに要素型がどのように計算されるかを追跡します。次に、Julia のリンクされた Base.promote_typejoin 実装を読み、その後 A と ArrayLikeBlock{A} に対する getindex の推論がどのように動作するかを調べます。完了の条件は、意図された Union 型を Any ではなく保持しながら、説明されている代入に対する型安定性を改善することです。

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

説明

data-structures enhancement performance

Currently, if one sets a PartialArray to have an element of type A and another element of type ArrayLikeBlock{A} (quite a common situation) the element type of the array becomes Any. This is a bit unfortunate, because if the type was kept as a Union{A, ArrayLikeBlock{A}} then getindex could infer its return type to be A, and we would have better type stability.

The fix for this would be to define our own typejoin alternative, that special cases ArrayLikeBlock to create Union types. This would be a lot like what the (unexported) Base.promote_typejoin does (see here) for Nothing and Missing. However we can't directly copy over that implementation because our special case type is an abstract type with type parameters, and we need to think through how to do this properly.

This is purely a performance optimisation, improving type stability for cases where some variables in an array are set with ranges and others are set as individual elements, and thus not very high priority.

主要言語
Julia
スター
291
フォーク
43
平均マージ
1日 23時間
マージ済み PR(30日)
15

環境構築

はじめの一歩

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

TuringLang/DynamicPPL.jl のほかの issue

TuringLang/DynamicPPL.jl の issue をすべて見る

似ている issue

Julia の issue をもっと見る

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

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