Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡️ Speed up method Photo.api_get by 8% in facebook_business/adobjects/photo.py #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions facebook_business/adobjects/photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from facebook_business.adobjects.objectparser import ObjectParser
from facebook_business.api import FacebookRequest
from facebook_business.typechecker import TypeChecker
import warnings

"""
This class is auto-generated.
Expand Down Expand Up @@ -108,13 +109,10 @@ def api_delete(self, fields=None, params=None, batch=None, success=None, failure
return request.execute()

def api_get(self, fields=None, params=None, batch=None, success=None, failure=None, pending=False):
from facebook_business.utils import api_utils
if batch is None and (success is not None or failure is not None):
api_utils.warning('`success` and `failure` callback only work for batch call.')
param_types = {
}
enums = {
}
if batch is None and (success or failure):
warnings.warn('`success` and `failure` callback only work for batch call.')
param_types = {}
enums = {}
request = FacebookRequest(
node_id=self['id'],
method='GET',
Expand All @@ -127,15 +125,13 @@ def api_get(self, fields=None, params=None, batch=None, success=None, failure=No
)
request.add_params(params)
request.add_fields(fields)

if batch is not None:
request.add_to_batch(batch, success=success, failure=failure)
return request
elif pending:
if pending:
return request
else:
self.assure_call()
return request.execute()
self.assure_call()
return request.execute()

def get_comments(self, fields=None, params=None, batch=None, success=None, failure=None, pending=False):
from facebook_business.utils import api_utils
Expand Down