Skip to content

Conversation

@jameslamb
Copy link
Collaborator

@jameslamb jameslamb commented Jun 27, 2023

Fixes #5313.

Removes handle attribute from the public API in the Python package, with the following changes:

  • Booster.handle -> Booster._handle
  • Dataset.handle -> Dataset._handle
  • _InnerPredictor.handle -> _InnerPredictor._handle

Why?

Making this implementation detail private allows changing it in the future without breaking user code.

@StrikerRUS originally recommended this, and I agree: #5313 (comment)

What about the R package?

Handles are already private there.

private$handle <- handle

private$handle <- handle

How impactful will this be?

I don't know for sure what uses cases are out there where people are relying on the handle attribute being public in the Python package. But I did a quick check of popular open source projects relying on lightgbm (https://www.wheelodex.org/projects/lightgbm/rdepends/) and didn't find any uses there:

@jameslamb jameslamb changed the title WIP: [python-package] make Booster and Dataset 'handle' attributes private (fixes #5313) [python-package] make Booster and Dataset 'handle' attributes private (fixes #5313) Jun 27, 2023
@jameslamb jameslamb marked this pull request as ready for review June 27, 2023 02:56
@jameslamb jameslamb requested a review from guolinke June 27, 2023 19:55
@jameslamb jameslamb mentioned this pull request Jun 28, 2023
60 tasks
@jameslamb jameslamb merged commit b8cc873 into master Jun 29, 2023
@jameslamb jameslamb deleted the internalize-handle branch June 29, 2023 13:02
@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2023

This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[python-package] prefix all internal object names with "_"

3 participants