This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Python str concat benchmark | |
Copyright (C) 2013-2020 by Denis Ryzhkov <[email protected]> | |
MIT License, see http://opensource.org/licenses/MIT | |
""" | |
from time import time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Verifying my Blockstack ID is secured with the address 1MXheoyjoKQpkSo4m5xgNEh1ngB97PEu9g https://explorer.blockstack.org/address/1MXheoyjoKQpkSo4m5xgNEh1ngB97PEu9g |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.postgres.fields import JSONField | |
from graphene.types.generic import GenericScalar | |
from graphene.utils.str_converters import to_camel_case, to_snake_case | |
from graphene_django.converter import convert_django_field | |
def patch_graphene_django_JSONField_converter(auto_camel_case=True): | |
""" | |
Ask `graphene_django` to convert `JSONField` to `GenericScalar` (JSON as is) instead of default `JSONString` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import graphene_django | |
def patch_graphene_django_choices_converter(): | |
""" | |
Prevent `graphene_django` from converting Django `choices` to `graphene.Enum` constants | |
Pros: | |
- Ints like 7 are not converted to "A_7" | |
- Strings like "Some String" are not converted to "SOME_STRING" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import greenlet, time, sys | |
def sys_profiler(frame, event, arg): | |
if event == 'call' or event == 'return': | |
code = frame.f_code | |
print('g{} {} {}:{} {}()'.format(id(greenlet.getcurrent()), event, code.co_filename, code.co_firstlineno, code.co_name)) | |
sys.setprofile(sys_profiler) |