Skip to content

Conversation

@umax
Copy link
Contributor

@umax umax commented Apr 4, 2018

Notes for struct usage optimizations: https://docs.python.org/2/library/struct.html#classes
Regarding string formatting:

In [1]: %timeit '%s' % 1
14.7 ns ± 0.325 ns per loop (mean ± std. dev. of 7 runs, 100000000 loops each)

In [2]: %timeit '{0}'.format(1)
134 ns ± 2.93 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)

Copy link
Contributor

Choose a reason for hiding this comment

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

put an _ in front of these so they aren't exported

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Copy link
Contributor

Choose a reason for hiding this comment

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

Explain what you're doing a bit more. Not everyone will have seen the relevant talks by Raymond Hettinger

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I know why this works, but someone reading this code might not. A quick comment will help future readers of the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@umax umax force-pushed the struct-usage-improvements branch from 223267c to 1b295a7 Compare April 4, 2018 08:47
@umax umax force-pushed the struct-usage-improvements branch from 1b295a7 to adaad2d Compare April 4, 2018 13:02
@brian-brazil brian-brazil merged commit a5e7c4e into prometheus:master Apr 5, 2018
@brian-brazil
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants