Skip to content

Conversation

@andrewgsavage
Copy link
Collaborator

  • Closes Create option to humanize time output  #2080
  • Executed pre-commit run --all-files with no errors
  • The change is fully covered by automated unit tests
  • Documented in docs/ as appropriate
  • Added an entry to the CHANGES file

@mmarras

I've made this it's own function as:

  • the logic is different to to_compact
  • there are instances where you may wish to use to_compact and to_human, or to_human alone

I'm open to other names than to_human!

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 16, 2024

CodSpeed Performance Report

Merging #2094 will not alter performance

Comparing andrewgsavage:human (ac21dc7) with master (861953e)

Summary

✅ 437 untouched benchmarks

@mmarras
Copy link

mmarras commented Dec 10, 2025

Thanks for picking this up!

I've made this it's own function as:
the logic is different to to_compact
there are instances where you may wish to use to_compact and to_human, or to_human alone

I don’t fully understand how it’s fundamentally different from to_compact

to_compact() works by changing the SI prefix

to_human() works by changing the unit itself

so why not a merged signature? Can you explain what you mean with the logic is different? In my mind the intention is the same: get a compact magnitude (and there are two options to do that, si prefix scaling or base-unit scaling).

Hence why not as originally proposed integration with to_compact?

to_compact(mode=“prefix”) original behavior and default mode for backwards compatibility
to_compact(mode=“units”, unitcandidates=[])

would make conceptually sense to me. Also I see no reason why chaining those two variants wouldn’t work like below:

pseudocode:
Q(7300,”h”).to_compact(unitcand=[Q(1,“month”).u, Q(1,”d”).u]).to_compact()= 1 deci month

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.

Create option to humanize time output

2 participants