Speed up validating table data

I am very new to playwright and front end automation in general. I didn't see a way to nativly do what I was looking for, so I wrote some custom functions. Let's say I have a table with the following columns

  • First Name
  • Last Name
  • Age
  • City
  • State

I have a function that I can pass any number of key value pairs in a dictionary and it assumes that is a header and column value. {First Name: John, Last Name: Doe, City: Miami} and it will return the matching rows. It finds the table on the page, pulls all the headers, matches the headers to my keys, and only searches on those indexes of the rows for the given values.

It works, but the problem is it is really slow. I expect this when I am writing new data to the table and it needs to load. But it is still really slow when I know that data is already existing on the table. I currently return the locator of the matching row/rows because I then may need to interact with that row.

Am I fundamentally approaching this wrong? I know this problem must have been solved before and maybe I am missing something super basic.

Update - The issue seemed to be how I was grabbing and navigating the table data. I added a bit of efficiency there and now it takes just a few seconds to validate 40ish rows.