Skip to content

Commit 937be4c

Browse files
Add more comments.
1 parent 68433af commit 937be4c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Python/pytime.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,13 @@ pytime_double_to_denominator(double d, time_t *sec, long *numerator,
363363
}
364364

365365

366+
/* Convert a number to a fraction representation.
367+
*
368+
* Set *ratio to a 2-tuple (numerator, denominator) and return 1 on success.
369+
* Return 0 if the number has neither the as_integer_ratio() method nor
370+
* the numerator and denominator attributes.
371+
* Return -1 on error.
372+
*/
366373
static int
367374
maybe_as_integer_ratio(PyObject *number, PyObject **ratio)
368375
{
@@ -416,6 +423,7 @@ maybe_as_integer_ratio(PyObject *number, PyObject **ratio)
416423
return *ratio ? 1 : -1;
417424
}
418425

426+
/* PyNumber_Divmod() that always returns a 2-tuple. */
419427
static PyObject *
420428
checked_divmod(PyObject *a, PyObject *b)
421429
{
@@ -439,6 +447,8 @@ checked_divmod(PyObject *a, PyObject *b)
439447
return result;
440448
}
441449

450+
/* Calculate numerator / denominator rounded to integer using
451+
* the specified rounding mode. */
442452
static PyObject *
443453
divide_and_round(PyObject *numerator, PyObject *denominator, _PyTime_round_t round)
444454
{
@@ -483,6 +493,8 @@ divide_and_round(PyObject *numerator, PyObject *denominator, _PyTime_round_t rou
483493
return result;
484494
}
485495

496+
/* Calculate scale * numerator / denominator rounded to integer using
497+
* the specified rounding mode. */
486498
static PyObject *
487499
multiply_divide_and_round(long scale, PyObject *numerator, PyObject *denominator,
488500
_PyTime_round_t round)

0 commit comments

Comments
 (0)