Description
to_json (and potentially others) handles the conversion of datetime-like objects to either epoch or isoformats depending on user input. All of this logic is currently housed in the objToJSON.c file and is a major reason why that extension module is rather complex / convoluted.
I think these methods may be general purpose enough to define in a vectorized manner on DatetimeLikeArrays. This wouldn't fully eliminate the need for the objToJSON.c extension module to define serialization for datetimes, timedelta and period object (as items stuck within an object array still need to be serialized), but it would definitely allow it to be more performant and move some of the logic out of the C layer back into Python
@jbrockmendel this is potentially also a precursor to #19486