Skip to content

Commit abea16f

Browse files
committed
Use @lionel-'s suggestion in vec_ptype() documentation
1 parent 02e73c0 commit abea16f

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

R/type.R

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@
3939
#' See [internal-faq-ptype2-identity] for more information about
4040
#' identity values.
4141
#'
42-
#' For performance, when developing a new S3 class you might want to override
43-
#' the default behavior of `vec_ptype()`, which is to call `vec_slice(x, 0L)`.
44-
#' To do this, write a `vec_ptype()` S3 method for your class. The method should
45-
#' return a result equivalent to `vec_slice(x, 0L)`, but for many classes this
46-
#' is a static object.
42+
#' `vec_ptype()` is a _performance_ generic. It is not necessary to implement it
43+
#' because the default method will work for any vctrs type. However the default
44+
#' method builds around other vctrs primitives like `vec_slice()` which incurs
45+
#' performance costs. If your class has a static prototype, you might consider
46+
#' implementing a custom `vec_ptype()` method that returns a constant. This will
47+
#' improve the performance of your class in many cases ([common
48+
#' type][vec_ptype2] imputation in particular).
4749
#'
4850
#' Because it may contain unspecified vectors, the prototype returned
4951
#' by `vec_ptype()` is said to be __unfinalised__. Call

man/vec_ptype.Rd

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)