Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLN: avoid runtime imports #27461

Merged
merged 14 commits into from
Jul 22, 2019
Merged

CLN: avoid runtime imports #27461

merged 14 commits into from
Jul 22, 2019

Conversation

jbrockmendel
Copy link
Member

Edits to lib.is_scalar are to put slower python-space checks later so they may get short-circuited.

Everything else should be self-explanatory.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any perf differences?

@jbrockmendel
Copy link
Member Author

any perf differences?

PR

In [3]: %timeit is_scalar(None)                                                                                                                                                                                                                   
55.1 ns ± 0.745 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)

master

In [3]: %timeit is_scalar(None)                                                                                                                                                                                                                   
588 ns ± 25.7 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

Presumably anything that is caught by the isinstance(Fraction, Number) would take a hit, but the difference when I pass an int or float is within the margin of error, and it isn't clear what else would be caught by that isinstance check. Also no difference when passing a list, which is what we'd expect.

@TomAugspurger TomAugspurger added the Performance Memory or execution speed performance label Jul 19, 2019
@TomAugspurger TomAugspurger added this to the 0.26.0 milestone Jul 19, 2019
Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @jreback any concerns?

@jreback
Copy link
Contributor

jreback commented Jul 19, 2019

i will look at things tomorrow

@jreback jreback modified the milestones: 0.26.0, 1.0 Jul 20, 2019
@@ -4,7 +4,7 @@
"""
import warnings

from pandas.core.dtypes.common import is_bool
from pandas._libs.lib import is_bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the correct import; we really really don't want to import directly from .lib for things like this, these should always be from pandas.core.dtypes.common.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't a hill i want to die on, but the dependency structure consideration is that util._* are supposed to be "upstream" of core

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't enforce that in any way and this is a complete style break.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will change

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, ping on green.

@jbrockmendel
Copy link
Member Author

ping

@jreback jreback merged commit ed48765 into pandas-dev:master Jul 22, 2019
@jreback
Copy link
Contributor

jreback commented Jul 22, 2019

thanks

@jbrockmendel jbrockmendel deleted the deps branch July 22, 2019 14:08
quintusdias pushed a commit to quintusdias/pandas_dev that referenced this pull request Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Memory or execution speed performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants