There are about 100 distinct methods named `number_of_xxx`. I'm a bit sceptical that changing or aliasing these to `num_xxx` is a good idea - mostly because of tab completion.
Martin On Wednesday, 24 September 2025 at 16:39:57 UTC+2 Vincent Macri wrote: > I agree that consistency is good. I prefer underscore naming, I find it > more readable and it's what PEP 8 recommends. I think number_of_facets is a > bit too long for my tastes (mostly because we try to adhere to line length > limits and long names make that annoying). If I were writing that code I'd > probably call it num_facets. > > Of course how much of a problem a long name is depends on how often it's > used. If we renamed the matrix nrows and ncols to number_of_rows and > number_of_columns then it would be very annoying to write an if statement > to check the matrix size against some other values and have that line fit > in 80 characters (sure you can wrap it, but I think that hurts > readability). Perhaps number_of_facets is not used so much that this is an > actual problem. But I think num_facets is a happy medium that is both clear > and short enough to not be annoying, which means that naming scheme can be > used consistently. > > For methods that are used very frequently (ncols, nrows, ngens, etc.) I > think it's probably fine to leave them as-is. We could add aliases for > num_cols, num_rows, etc. if we want. > > I recently added functionality to our documentation builder ( > https://github.com/sagemath/sage/pull/40753) to detect aliased functions > and methods and not duplicate them in the HTML docs (it now says "alias of > [link to original]", before it just duplicated the docstring including all > the examples) so bloating the documentation with aliases isn't really a > problem anymore (in case someone was worried about that). > > One thing I would note is that changing the name of nfacets is technically > a breaking change and there should be an alias for the old name with a > deprecation warning in place for however long our depreciation period is. > > Also, thank you Frédéric for all the refactoring and code cleanup work > you've been doing! > > Vincent Macri (he/him) > > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/sage-devel/191f10f1-f41f-45c8-bf5f-3a18fe44b4d1n%40googlegroups.com.
