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

Use datetime.utcfromtimestamp instead of first using gmtime in CTime.datetime #909

Closed
wants to merge 1 commit into from

Conversation

JHolba
Copy link

@JHolba JHolba commented Sep 27, 2023

This makes datetime run about 10% faster.

measured using this python code

import timeit

runtime = timeit.timeit(
    "time_map = [t.datetime() for t in c_time]",
    "from ecl.summary import EclSum;"
    'summary = EclSum("/home/jholba/Downloads/BIGPOLY",include_restart=False,lazy_load=False);'
    "c_time = summary.alloc_time_vector(True)",
    number=100,
)

print(runtime)

@JHolba JHolba closed this Sep 27, 2023
@JHolba JHolba deleted the make_ctime_datetime_faster branch September 27, 2023 13:56
@JHolba JHolba restored the make_ctime_datetime_faster branch September 27, 2023 13:58
@JHolba JHolba reopened this Sep 27, 2023
@@ -50,7 +50,7 @@ def date(self):
return datetime.date(*self.time()[0:3])

def datetime(self):
return datetime.datetime(*self.time()[0:6])
return datetime.datetime.utcfromtimestamp(self.ctime())
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe not measurably faster, but by inlining self.ctime() to self.value() you should save a function call.

@pinkwah
Copy link
Collaborator

pinkwah commented Dec 22, 2023

Stale?

@JHolba JHolba closed this Jan 10, 2024
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.

3 participants