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

Convert POSIXct to Date directly #2

Merged
merged 1 commit into from
Oct 20, 2018

Conversation

joshuaulrich
Copy link
Sponsor Contributor

As of R-3.5.1, converting from POSIXct to Date creates an intermediate
POSIXlt vector. This uses a non-trivial amount of memory. Directly
converting from POSIXct to Date uses less memory and is roughly twice
as fast.

This solution is a combination of asPOSIXlt and POSIXlt2D from RCore.
The functions are essentially concatenated, with the extraneous parts
removed.

The function name 'asDatePOSIXct' differs from the other rapi* names
because it's not a RCore function. The name isn't as.Date.POSIXct() to
avoid clashes with the current (or future) S3 method.

As of R-3.5.1, converting from POSIXct to Date creates an intermediate
POSIXlt vector. This uses a non-trivial amount of memory. Directly
converting from POSIXct to Date uses less memory and is roughly twice
as fast.

This solution is a combination of asPOSIXlt and POSIXlt2D from RCore.
The functions are essentially concatenated, with the extraneous parts
removed.

The function name 'asDatePOSIXct' differs from the other rapi* names
because it's not a RCore function. The name isn't as.Date.POSIXct() to
avoid clashes with the current (or future) S3 method.
@codecov-io
Copy link

Codecov Report

Merging #2 into master will increase coverage by 1.42%.
The diff coverage is 84.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #2      +/-   ##
==========================================
+ Coverage   53.24%   54.67%   +1.42%     
==========================================
  Files           5        6       +1     
  Lines         971     1017      +46     
==========================================
+ Hits          517      556      +39     
- Misses        454      461       +7
Impacted Files Coverage Δ
R/asDatePOSIXct.R 100% <100%> (ø)
src/init.c 100% <100%> (ø) ⬆️
src/datetime.c 66.71% <82.05%> (+0.97%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 84aa1b0...6bc9320. Read the comment docs.

Copy link
Owner

@eddelbuettel eddelbuettel left a comment

Choose a reason for hiding this comment

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

Looks fabulous, and helpful.

@eddelbuettel eddelbuettel merged commit ad44621 into eddelbuettel:master Oct 20, 2018
@joshuaulrich joshuaulrich deleted the asDate-POSIXct branch October 20, 2018 14:12
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.

None yet

3 participants