facebookresearch / dlrm

An implementation of a deep learning recommendation model (DLRM)
MIT License
3.71k stars 825 forks source link

Replace hasattr with getattr in ai_codesign/benchmarks/dlrm/torchrec_dlrm/data/dlrm_dataloader.py #344

Closed joshuadeng closed 1 year ago

joshuadeng commented 1 year ago

Summary: The pattern

X.Y if hasattr(X, "Y") else Z

can be replaced with

getattr(X, "Y", Z)

The getattr function gives more succinct code than the hasattr function. Please use it when appropriate.

This diff is very low risk. Green tests indicate that you can safely Accept & Ship.

Differential Revision: D44886546

facebook-github-bot commented 1 year ago

This pull request was exported from Phabricator. Differential Revision: D44886546