Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Django 4.1のAsynchronous

Junya Fukuda
November 12, 2022

Django 4.1のAsynchronous

talk about "Asynchronous ORM interface, Asynchronous handlers for class-based views".
Nov 12, 2022
DjangoCongress JP 2022 at NIKKEI Conference Room Nikkei Building
https://djangocongress.jp/

Junya Fukuda

November 12, 2022
Tweet

More Decks by Junya Fukuda

Other Decks in Technology

Transcript

  1. Django 4.1 での Asynchronous Junya Fukuda DjangoCongress JP 2022

  2. •෱ా ൏໵ʢJunya Fukudaʣʢ@JunyaFffʣ •גࣜձࣾ೔ຊγεςϜٕݚʢJSLʣॴଐ ௕໺ݝͷձࣾ •WebΤϯδχΞ •GEEKLAB.NAGANO - ίϛϡχςΟεϖʔεӡӦ •ʢ͓͠͝ͱͰʣόϦϡʔϒοΫε

    •ຊ޷͖ʹѪ͞ΕΔαʔϏεΛ໨ࢦͯ͠ʢݹຊങऔɾൢചʣ •GEEKLAB.NAGANO - ίϛϡχςΟεϖʔεӡӦ
  3. Python実践 •2022೥1݄ൃച ٕज़ධ࿦ࣾ •Python 3 ΤϯδχΞೝఆ࣮ફࢼݧ ओڭࡐ •2࡭໨ʹ͓͢͢Ίʂࣙॻతʹ࢖͍ͬͯ͋͛ͯͩ͘͞ʂ • ҎԼͷষΛ୲౰͍ͯ͠·͢

    • Chapter2 ίʔσΟϯάن໿ • Chapter5 ܕώϯτ • Chapter19 ฒߦॲཧɼฒྻॲཧ
  4. Django 4.1 での ⾮同期

  5. Pythonで⾮同期、使っていますか?✋

  6. ありがとうございます。

  7. ですよね。 なぜ使わないのでしょうか?

  8. ⾮同期 使 理由 考 •׳ΕͯΔಉظॲཧͰे෼ •IO͕ͳ͍ʢػցֶश΍σʔλ෼ੳ͕த৺ʣʢCPUʹ͕Μ͹ΒͤΔ͜ͱଟ͍ʣ •ඇಉظॲཧͬͯɺ༧ଌͰ͖ͳ͍ಈ͖Λͦ͠͏ •ଞͷݴޠͰॻ͍ͪΌ͏ʢGo΍JS(nodejs/deno..),Rust,C#,SwiftͳͲʣ

  9. None
  10. Djangoの⾮同期対応を待ってるのです

  11. Django 4.1 Asynchronous IUUQTEPDTEKBOHPQSPKFDUDPNFOSFMFBTFT

  12. Django 4.1 Asynchronous IUUQTEPDTEKBOHPQSPKFDUDPNFOSFMFBTFT

  13. Django 4.1 Asynchronous IUUQTEPDTEKBOHPQSPKFDUDPNFOSFMFBTFT

  14. Django 4.1 Asynchronous IUUQTEPDTEKBOHPQSPKFDUDPNFOSFMFBTFT Note that, at this stage, the

    underlying database operations remain synchronous
  15. Django 4.1 Asynchronous ͜ͷஈ֊Ͱ͸ɺجຊతͳσʔλϕʔεૢ࡞͸ಉظͷ··Ͱ͋Δ͜ͱʹ஫ҙ͍ͯͩ͘͠͞ɻ IUUQTEPDTEKBOHPQSPKFDUDPNFOSFMFBTFT Note that, at this stage,

    the underlying database operations remain synchronous
  16. 🤔

  17. 🤔 ͳͥɺ03.͸ΠϯλʔϑΣʔε͚ͩରԠͨ͠ΜͩΖ͏ ͍·ɺ%KBOHPͷඇಉظରԠ࣮ͬͯࡍͲ͏ͳ͍ͬͯΔΜͩΖ͏ʜ

  18. ( 話 ?) •ڈ೥ͷDjangoCongress JP 2021 ͰͷτʔΫΛΞοϓσʔτ͍ͨ͠ •Django 3.2 ASGI

    ରԠ - ͜Θ͘ͳ͍ asyncio جૅͱ async view ͷ࢖͍ॴ IUUQTMPHNJKQUFDIBSUJDMFT •DjangoͷORM͸ͳͥਖ਼ࣜରԠͰ͸ͳ͍ͷ͔ •΋͔ͨ͠͠Βͦ͏ࢥΘΕͨํ΋͍Βͬ͠ΌΔ͔΋͠Ε·ͤΜʢΘͨ͠
  19. 本⽇ •Django 4.1 ඇಉظରԠ͕Θ͔ͬͨ •ΫϥεϕʔεϏϡʔ •ORMͷΠϯλʔϑΣʔε •Ωʔϫʔυ͸ •·ͨඇಉظORMΠϯλʔϑΣʔε͸ͳͥ׬શରԠͰ͸ͳ͘ɺಉظͷ··ͳͷ͔ ޓ׵ੑ

  20. 話 ・話 •DjangoͷViewͷجຊతͳ࢓૊Έ •Djangoͷmodelͷఆٛ •asyncioͷࡉ͔͍͜ͱ •࿩͞ͳ͍͜ͱ •࿩͢͜ͱ •Django 4.1ͷΫϥεϕʔεϏϡʔɾORM

  21. •Django 4.1 ඇಉظରԠͱ͍··Ͱͷ͓͞Β͍ •ΫϥεϕʔεϏϡʔͷඇಉظରԠ •؆୯ͳίʔυ ΫϥεϕʔεϏϡʔͷ಺ଆ •ಉظɾඇಉظΫϥεϕʔεϏϡʔͰͷಈ࡞ൺֱ •ඇಉظ ORM ΠϯλʔϑΣʔε

    •֓ཁ •ಉظɾඇಉظORMͰͷಈ࡞ൺֱ •ඇಉظORM ΠϯλʔϑΣʔεͷ޲͜͏ଆ
  22. •Django 4.1 ඇಉظରԠͱ͍··Ͱͷ͓͞Β͍ •ΫϥεϕʔεϏϡʔͷඇಉظରԠ •؆୯ͳίʔυ ΫϥεϕʔεϏϡʔͷ಺ଆ •ಉظɾඇಉظΫϥεϕʔεϏϡʔͰͷಈ࡞ൺֱ •ඇಉظ ORM ΠϯλʔϑΣʔε

    •֓ཁ •ಉظɾඇಉظORMͰͷಈ࡞ൺֱ •ඇಉظORM ΠϯλʔϑΣʔεͷ޲͜͏ଆ
  23. - Django ⾮同期対応 •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ

  24. - Django ⾮同期対応 •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ

  25. - Django ⾮同期対応 2005 Django OSS •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ

  26. - Django ⾮同期対応 2005 Django OSS 1.0 2008 •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ

  27. - Django ⾮同期対応 2005 Django OSS 1.0 1.4 LTS 2012

    2008 •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ
  28. - Django ⾮同期対応 2005 Django OSS 1.0 1.4 LTS 1.8

    LTS 2015 2012 2008 •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ
  29. - Django ⾮同期対応 2005 Django OSS 1.0 1.4 LTS 1.8

    LTS 1.11 LTS 2.0 2017 2015 2012 2008 •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ
  30. - Django ⾮同期対応 2005 Django OSS 1.0 1.4 LTS 1.8

    LTS 1.11 LTS 2.0 2.2 LTS 3.0 2019 2017 2015 2012 2008 •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ
  31. - Django ⾮同期対応 2005 Django OSS 1.0 1.4 LTS 1.8

    LTS 1.11 LTS 2.0 2.2 LTS 3.0 3.2 LTS 4.0 2021 2019 2017 2015 2012 2008 •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ
  32. - Django ⾮同期対応 2005 Django OSS 1.0 1.4 LTS 1.8

    LTS 1.11 LTS 2.0 2.2 LTS 3.0 3.2 LTS 4.0 4.1 2022 2021 2019 2017 2015 2012 2008 •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ
  33. - Django ⾮同期対応 2005 Django OSS 1.0 1.4 LTS 1.8

    LTS 1.11 LTS 2.0 2.2 LTS 3.0 3.2 LTS 4.0 4.1 4.2 LTS 2023 2022 2021 2019 2017 2015 2012 2008 •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ
  34. - Django ⾮同期対応 1.4 LTS 1.8 LTS 1.11 LTS 2.0

    3.0 3.2 LTS 4.1 4.2 LTS 2023 2022 2021 2019 2017 2015 2012 2.2 LTS •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ
  35. - Django ⾮同期対応 1.4 LTS 1.8 LTS 1.11 LTS 2.0

    3.0 3.2 LTS 4.1 4.2 LTS 2023 2022 2021 2019 2017 2015 2012 2014 Python 3.4 asyncio 2.2 LTS •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ
  36. - Django ⾮同期対応 1.4 LTS 1.8 LTS 1.11 LTS 2.0

    3.0 3.2 LTS 4.1 4.2 LTS 2023 2022 2021 2019 2017 2015 2012 2014 Python 3.4 asyncio async/await Python 3.5 2.2 LTS •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ
  37. - Django ⾮同期対応 1.4 LTS 1.8 LTS 1.11 LTS 2.0

    3.0 3.2 LTS 4.1 4.2 LTS 2023 2022 2021 2019 2017 2015 2012 2014 Python 3.4 asyncio async/await 2016 Python 3.5 asgiref 1.0 2.2 LTS •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ
  38. - Django ⾮同期対応 1.4 LTS 1.8 LTS 1.11 LTS 2.0

    2.2 LTS 3.0 3.2 LTS 4.1 4.2 LTS 2023 2022 2021 2019 2017 2015 2012 2014 Python 3.4 asyncio async/await asgiref 1.0 2016 Python 3.5 channels •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ
  39. - Django ⾮同期対応 1.4 LTS 1.8 LTS 1.11 LTS 2.0

    2.2 LTS 3.0 3.2 LTS 4.1 4.2 LTS 2023 2022 2021 2019 2017 2015 2012 2014 Python 3.4 asyncio async/await asgiref 1.0 2016 Python 3.5 channels asgiref 3.0 •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ
  40. - Django ⾮同期対応 1.4 LTS 1.8 LTS 1.11 LTS 2.0

    2.2 LTS 3.2 LTS 4.1 4.2 LTS 2023 2022 2021 2019 2017 2015 2012 2014 Python 3.4 asyncio async/await asgiref 1.0 2016 Python 3.5 channels asgiref 3.0 3.0 asgiରԠ •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ
  41. - Django ⾮同期対応 1.4 LTS 1.8 LTS 1.11 LTS 2.0

    2.2 LTS 3.2 LTS 4.1 4.2 LTS 2023 2022 2021 2019 2017 2015 2012 2014 Python 3.4 asyncio async/await asgiref 1.0 2016 Python 3.5 channels asgiref 3.0 3.0 ؔ਺view asgiରԠ •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ
  42. - Django ⾮同期対応 1.4 LTS 1.8 LTS 1.11 LTS 2.0

    2.2 LTS 3.2 LTS 4.1 4.2 LTS 2023 2022 2021 2019 2017 2015 2012 2014 Python 3.4 asyncio async/await asgiref 1.0 2016 Python 3.5 channels asgiref 3.0 3.0 asgiରԠ ؔ਺view ΫϥεϏϡʔ ORM IF •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ
  43. - Django ⾮同期対応 1.4 LTS 1.8 LTS 1.11 LTS 2.0

    2.2 LTS 3.2 LTS 4.1 4.2 LTS 2023 2022 2021 2019 2017 2015 2012 2014 Python 3.4 asyncio async/await asgiref 1.0 2016 Python 3.5 channels asgiref 3.0 3.0 asgiରԠ ؔ਺view ΫϥεϏϡʔ ORM IF •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ
  44. - Django ⾮同期対応 1.4 LTS 1.8 LTS 1.11 LTS 2.0

    2.2 LTS 3.2 LTS 4.1 4.2 LTS 2023 2022 2021 2019 2017 2015 2012 2014 Python 3.4 asyncio async/await asgiref 1.0 2016 Python 3.5 channels asgiref 3.0 3.0 asgiରԠ ؔ਺view ΫϥεϏϡʔ ORM IF DEP 0009: Async-capable DjangoʢDEP͸DjangoͷPEPʣ •Έͳ͞Μ͕ॳΊͯ͞ΘͬͨDjangoͷόʔδϣϯ͸͍ͭ͘Ͱ͠ΐ͏͔ʁ
  45. - asyncio 基本 •ඇಉظॲཧͷίʔυΛॻͨ͘ΊͷެࣜϥΠϒϥϦ •ෳ਺ͷλεΫΛಉ࣌ʹॲཧ͢Δ •I/Oό΢ϯυͳॲཧʢDBΞΫηε/HTTPϦΫΤετͳͲʣͰޮՌΛൃش •֎෦API-A, ֎෦API-B, ֎෦API-C Λಉ࣌ʹ࣮ߦ͍ͨ͠

    •ಉظॲཧͩͱ ॱ൪ʹ࣮ߦ " # $
  46. - asyncio 基本 •ඇಉظॲཧͷίʔυΛॻͨ͘ΊͷެࣜϥΠϒϥϦ •ෳ਺ͷλεΫΛಉ࣌ʹॲཧ͢Δ •I/Oό΢ϯυͳॲཧʢDBΞΫηε/HTTPϦΫΤετͳͲʣͰޮՌΛൃش •֎෦API-A, ֎෦API-B, ֎෦API-C Λಉ࣌ʹ࣮ߦ͍ͨ͠

    •ඇಉظॲཧͩͱ ·ͱΊͯಉ࣌ʹ࣮ߦ C B A
  47. - asyncio 基本 •ඇಉظॲཧͷίʔυΛॻͨ͘Ίͷඪ४ϥΠϒϥϦ •ຖόʔδϣϯਐԽ ߴϨϕϧAPI͕ॆ࣮ - ͱͯ΋ॻ͖΍͍͢ •ෳ਺ͷλεΫΛಉ࣌ʹॲཧ͢Δ •I/Oό΢ϯυͳॲཧʢDBΞΫηε/HTTPϦΫΤετͳͲʣͰޮՌΛൃش

    •async/await ߏจ •λεΫΛొ࿥͢Δasyncio.create_task() - ʮλεΫʯ = ॲཧͩͱࢥ͍ͬͯͩ͘͞ɻ •ॲཧΛฒߦʹ͢Δasyncio.gather() •ྫ֎΍ΩϟϯηϧΛॊೈʹ asyncio.TaskGroup •αʔυύʔςΟͷϥΠϒϥϦΛ࢖͏৔߹ɺඇಉظରԠ͍ͯ͠Δඞཁ͕͋Δ
  48. Django

  49. Django 63- σΟεύο νϟʔ 63-DPOG Ϗϡʔ ϑΥʔϜ ςϯϓϨʔτ Ϟσϧ DjangoϓϩδΣΫτ

    ϒϥ΢β Webαʔό ΞϓϦέʔγϣϯαʔό ϦΫΤ ετ ֎෦Ϧιʔε ϛυϧ ΢ΣΞ Ϩεϙ ϯε
  50. Django 63- σΟεύο νϟʔ 63-DPOG Ϗϡʔ ϑΥʔϜ ςϯϓϨʔτ Ϟσϧ DjangoϓϩδΣΫτ

    ϒϥ΢β Webαʔό ΞϓϦέʔγϣϯαʔό ϦΫΤ ετ ֎෦Ϧιʔε ϛυϧ ΢ΣΞ Ϩεϙ ϯε ʮݱ৔Ͱ࢖͑ΔDjangoͷڭՊॻʯΛࢀߟʹ͍͖ͤͯͨͩ͞·ͨ͠
  51. Django 63- σΟεύο νϟʔ 63-DPOG Ϗϡʔ ϑΥʔϜ ςϯϓϨʔτ Ϟσϧ DjangoϓϩδΣΫτ

    ϒϥ΢β Webαʔό ΞϓϦέʔγϣϯαʔό ϦΫΤ ετ ֎෦Ϧιʔε ϛυϧ ΢ΣΞ Ϩεϙ ϯε ඇಉظରԠ ΫϥεϕʔεϏϡʔ 03.ΠϯλʔϑΣʔε
  52. Django 63- σΟεύο νϟʔ 63-DPOG Ϗϡʔ ϑΥʔϜ ςϯϓϨʔτ Ϟσϧ DjangoϓϩδΣΫτ

    ϒϥ΢β Webαʔό ΞϓϦέʔγϣϯαʔό ϦΫΤ ετ ֎෦Ϧιʔε ϛυϧ ΢ΣΞ Ϩεϙ ϯε ඇಉظରԠ ΫϥεϕʔεϏϡʔ 03.ΠϯλʔϑΣʔε
  53. Django 63- σΟεύο νϟʔ 63-DPOG Ϗϡʔ ϑΥʔϜ ςϯϓϨʔτ Ϟσϧ DjangoϓϩδΣΫτ

    ϒϥ΢β Webαʔό ΞϓϦέʔγϣϯαʔό ϦΫΤ ετ ֎෦Ϧιʔε ϛυϧ ΢ΣΞ Ϩεϙ ϯε ඇಉظରԠ ΫϥεϕʔεϏϡʔ 03.ΠϯλʔϑΣʔε
  54. •Django 4.1 ඇಉظରԠͱ͍··Ͱͷ͓͞Β͍ •ΫϥεϕʔεϏϡʔͷඇಉظରԠ •؆୯ͳίʔυ ΫϥεϕʔεϏϡʔͷ಺ଆ •ಉظɾඇಉظΫϥεϕʔεϏϡʔͰͷಈ࡞ൺֱ •ඇಉظ ORM ΠϯλʔϑΣʔε

    •֓ཁ •ಉظɾඇಉظORMͰͷಈ࡞ൺֱ •ඇಉظORM ΠϯλʔϑΣʔεͷ޲͜͏ଆ
  55. ⾮同期対応 •viewΫϥεͰίϧʔνϯͷఆ͕ٛՄೳ •django.views.generic.base.view ͢΂ͯͷviewͷ਌Ϋϥε •get, post, put, delete, ͳͲͷϦΫΤετϝιου͕ରԠ •؆୯ͳίʔυΛݟͯΈ·͠ΐ͏

  56. ΫϥεϕʔεϏϡʔͷඇಉظରԠ import asyncio from django.http import HttpResponse from django.views import

    View views.py
  57. ΫϥεϕʔεϏϡʔͷඇಉظରԠ import asyncio from django.http import HttpResponse from django.views import

    View views.py
  58. ΫϥεϕʔεϏϡʔͷඇಉظରԠ import asyncio from django.http import HttpResponse from django.views import

    View class AsyncView(View): views.py
  59. ΫϥεϕʔεϏϡʔͷඇಉظରԠ import asyncio from django.http import HttpResponse from django.views import

    View class AsyncView(View): async def get(self, request, *args, **kwargs): # Perform view logic using await. await asyncio.sleep(1) return HttpResponse("Hello async world!") views.py
  60. ΫϥεϕʔεϏϡʔͷඇಉظରԠ import asyncio from django.http import HttpResponse from django.views import

    View async def post(self, request, *args, **kwargs): ... async def put(self, request, *args, **kwargs): ... class AsyncView(View): async def get(self, request, *args, **kwargs): # Perform view logic using await. await asyncio.sleep(1) return HttpResponse("Hello async world!") views.py
  61. ΫϥεϕʔεϏϡʔͷඇಉظରԠ urlpatterns = [ ] urls.py

  62. ΫϥεϕʔεϏϡʔͷඇಉظରԠ urlpatterns = [ ] urls.py path('sample/', AsyncView.as_view(), name='sample'),

  63. ΫϥεϕʔεϏϡʔͷඇಉظରԠ urlpatterns = [ ] urls.py path('sample/', AsyncView.as_view(), name='sample'),

  64. ΫϥεϕʔεϏϡʔͷඇಉظରԠ import asyncio from django.http import HttpResponse from django.views import

    View async def post(self, request, *args, **kwargs): ... class AsyncView(View): async def get(self, request, *args, **kwargs): # Perform view logic using await. await asyncio.sleep(1) return HttpResponse("Hello async world!") views.py async def put(self, request, *args, **kwargs): ... ఆٛ࣌ͷ஫ҙ఺
  65. ΫϥεϕʔεϏϡʔͷඇಉظରԠ import asyncio from django.http import HttpResponse from django.views import

    View async def post(self, request, *args, **kwargs): ... class AsyncView(View): async def get(self, request, *args, **kwargs): # Perform view logic using await. await asyncio.sleep(1) return HttpResponse("Hello async world!") views.py async def put(self, request, *args, **kwargs): ... ఆٛ࣌ͷ஫ҙ఺
  66. ΫϥεϕʔεϏϡʔͷඇಉظରԠ import asyncio from django.http import HttpResponse from django.views import

    View def post(self, request, *args, **kwargs): ... class AsyncView(View): async def get(self, request, *args, **kwargs): # Perform view logic using await. await asyncio.sleep(1) return HttpResponse("Hello async world!") views.py async def put(self, request, *args, **kwargs): ... ఆٛ࣌ͷ஫ҙ఺
  67. ΫϥεϕʔεϏϡʔͷඇಉظରԠ import asyncio from django.http import HttpResponse from django.views import

    View def post(self, request, *args, **kwargs): ... class AsyncView(View): async def get(self, request, *args, **kwargs): # Perform view logic using await. await asyncio.sleep(1) return HttpResponse("Hello async world!") views.py async def put(self, request, *args, **kwargs): ... ఆٛ࣌ͷ஫ҙ఺ *NQSPQFSMZ$PO fi HVSFE
  68. ΫϥεϕʔεϏϡʔͷඇಉظରԠ import asyncio from django.http import HttpResponse from django.views import

    View async def post(self, request, *args, **kwargs): ... class AsyncView(View): async def get(self, request, *args, **kwargs): # Perform view logic using await. await asyncio.sleep(1) return HttpResponse("Hello async world!") views.py async def put(self, request, *args, **kwargs): ... ఆٛ࣌ͷ஫ҙ఺
  69. ⾮同期対応 •ίϛοτ͸1ͭ

  70. ⾮同期対応 •ίϛοτ͸1ͭ •मਖ਼͸ܰඍ υΩϡϝϯτɾςετΛআ͘ͱ30ߦఔ౓ IUUQTHJUIVCDPNEKBOHPEKBOHPQVMM

  71. Django/views/generics/base.py class View: ⾮同期対応 @classproperty def view_is_async(cls): handlers = [

    getattr(cls, method) for method in cls.http_method_names if (method != "options" and hasattr(cls, method)) ] if not handlers: return False is_async = asyncio.iscoroutinefunction(handlers[0]) if not all(asyncio.iscoroutinefunction(h) == is_async for h in handlers[1:]): raise ImproperlyConfigured( f"{cls.__qualname__} HTTP handlers must either be all sync or all " "async." ) return is_async
  72. Django/views/generics/base.py class View: ⾮同期対応 ... if cls.view_is_async: view._is_coroutine = asyncio.coroutines._is_coroutine

  73. Django/views/generics/base.py class View: ⾮同期対応 ... if self.view_is_async: async def func():

    return response return func() else: return response
  74. ⾮同期対応 •ίϛοτ͸1ͭ •मਖ਼͸ܰඍ υΩϡϝϯτɾςετΛআ͘ͱ30ߦఔ౓ IUUQTHJUIVCDPNEKBOHPEKBOHPQVMM •asgi.pyͳͲΛؚΊରԠͷ४උ͸੔͍ͬͯͨ

  75. 同期 ⾮同期 •ΫϥεϕʔεϏϡʔͰ֎෦APIΛ࣮ߦ͢Δྫ •ಉظɾඇಉظͰͦΕͧΕ ׬ྃ·Ͱͷ࣌ؒΛܭଌ •pokemonͷඇެࣜAPIʢओʹֶश޲͚ͷAPI ɺ༻๏༰ྔ͸कͬͯ •viewΫϥεΛར༻͠ɺςϯϓϨʔτͰදࣔ͢Δ •151ඖͷϙέϞϯͷ໊લΛऔಘ

  76. 同期 ⾮同期 •ಈ࡞؀ڥ - ϩʔΧϧ •MacBook Proʢ14Πϯνɺ2021ʣ •Apple M1 Pro

    ϝϞϦ32gb
  77. 同期処理 ⾮同期処理

  78. 同期処理 ⾮同期処理 requests

  79. ΫϥεϕʔεϏϡʔಉظίʔυ class PokeView(View): URL = "https://pokeapi.co/api/v2/pokemon/" def get(self, request, *args,

    **kwargs): start = time() pokemons = [] for number in range(1, 152): url = f'https://pokeapi.co/api/v2/pokemon/{number}' r = requests.get(url) pokemon = r.json() pokemons.append({"name" : pokemon['name']}) finish = (time() - start) context = {"pokemons": pokemons, "finish_time": finish} return render(request, “sync.html", context) views.py ֎෦APIΛ࣮ߦ
  80. urlpatterns = [ path('sync/', PokeView.as_view(), name=‘syncpoke'), ] ΫϥεϕʔεϏϡʔಉظίʔυ urls.py ֎෦APIΛ࣮ߦ

  81. ΫϥεϕʔεϏϡʔͷ ಉظίʔυ urls.py

  82. ΫϥεϕʔεϏϡʔͷ ಉظίʔυ urls.py

  83. ΫϥεϕʔεϏϡʔͷ ಉظίʔυ urls.py

  84. 同期処理 ⾮同期処理

  85. 同期処理 ⾮同期処理 httpx

  86. 同期処理 ⾮同期処理 httpx async対応のサードパーティライブラリ

  87. ΫϥεϕʔεϏϡʔඇಉظίʔυ class AsyncPokeView(View): URL = "https://pokeapi.co/api/v2/pokemon/" async def get(self, request,

    *args, **kwargs): start = time() async with httpx.AsyncClient() as client: tasks = [self.access_url_poke(client, number) for number in range(1, 152)] pokemmons = await asyncio.gather(*tasks, return_exceptions=True) finish = (time() - start) context = {"pokemons": pokemmons, "finish_time": finish} return render(request, "async.html", context) async def access_url_poke(self, client, num: int) -> str: r = await client.get(f"{self.URL}{num}") pokemon = r.json() return {"name": pokemon['name']} views.py ֎෦APIΛ࣮ߦ
  88. urlpatterns = [ path('async/', AsyncPokeView.as_view(), name=‘asyncpoke'), ] ΫϥεϕʔεϏϡʔඇಉظίʔυ urls.py ֎෦APIΛ࣮ߦ

  89. ΫϥεϕʔεϏϡʔඇಉظίʔυ ࣮ߦ݁Ռ ֎෦APIΛ࣮ߦ

  90. ΫϥεϕʔεϏϡʔඇಉظίʔυ ࣮ߦ݁Ռ ֎෦APIΛ࣮ߦ

  91. ΫϥεϕʔεϏϡʔඇಉظίʔυ ࣮ߦ݁Ռ ֎෦APIΛ࣮ߦ

  92. 同期 ⾮同期 •࣮ߦ݁Ռ •ಉظɿ18ඵ •ඇಉظɿ0.7ඵ •ඇಉظͱͯ΋͸΍͍ •APIΛ151ճ΋ୟ͘ඇಉظʹ༗རͳܭଌʢͻ͍͖ •ͦͷଞͷ࢖͍ํ - DjangoCon

    2022 •Async Django: The practical guide you've been *awaiting* for by Carlton Gibson •https://www.youtube.com/watch?v=B5uQPwX4VLo •֎෦APIΛಉ࣌ʹ࣮ߦ͢Δ৔߹ʹ࠾༻͠ͳ͍ख͸ͳ͍ •ʮඇಉظDjangoͷ͋ͳ͕ͨ଴ͪ๬ΜͰ͍࣮ͨ༻తͳΨΠυϒοΫʯνϟοτ Channels
  93. •Django 4.1 ඇಉظରԠͱ͍··Ͱͷ͓͞Β͍ •ΫϥεϕʔεϏϡʔͷඇಉظରԠ •؆୯ͳίʔυ ΫϥεϕʔεϏϡʔͷ಺ଆ •ಉظɾඇಉظΫϥεϕʔεϏϡʔͰͷಈ࡞ൺֱ •ඇಉظ ORM ΠϯλʔϑΣʔε

    •֓ཁ •ಉظɾඇಉظORMͰͷಈ࡞ൺֱ •ඇಉظORM ΠϯλʔϑΣʔεͷ޲͜͏ଆ
  94. ⾮同期 ORM •QuerySetͷϝιουʹ઀಄ࣙʮaʯ͕͍ͭͨඇಉظ൛͕௥Ճ •໋໊نଇ͸3ͭͷީิ 1."_async" pre fi x, 2."_async" suf

    fi x 3."a" pre fi x _async_get get_async aget ଞʹ΋a.getͳͲ •ٞ࿦ͷ຤ɺPythonͷํ޲ੑ(e.g. __aiter__, __anext__, __aenter__, __aexit__ etc.) •3͕࠾༻ʹ IUUQTGPSVNEKBOHPQSPKFDUDPNUOBNJOHPGBTZODWBSJBOUT
  95. ⾮同期 ORM •QuerySetͷϝιουʹ઀಄ࣙʮaʯ͕͍ͭͨඇಉظ൛͕௥Ճ •db.models.guery •aiterator, aaggregate, acount, aget, acreate, abulk_create,

    abulk_update, • aget_or_create, aupdate_or_create, aearliest, alatest, a fi rst, alast, ain_bulk, • aupdate, adelete, aexists, acontains, aexplain •ʢ´-`ʣ.ŇoOʢ໊લ͕ؾʹͳΔ΋ͷ΋͋Δ… acount, aggregate, adelete …ʣ •·ͣ͸؆୯ʹಈ͔ͯ͠Έ·͠ΐ͏
  96. ΫϥεϕʔεϏϡʔඇಉظίʔυ $ python manage.py shell Python 3.11.0 (v3.11.0:deaf509e8f, Oct 24

    2022, 14:43:23) [Clang 13.0.0 (clang-1300.0.29.30)] Type 'copyright', 'credits' or 'license' for more information IPython 8.6.0 -- An enhanced Interactive Python. Type '?' for help. views.py ֎෦APIΛ࣮ߦ
  97. ΫϥεϕʔεϏϡʔඇಉظίʔυ $ python manage.py shell Python 3.11.0 (v3.11.0:deaf509e8f, Oct 24

    2022, 14:43:23) [Clang 13.0.0 (clang-1300.0.29.30)] Type 'copyright', 'credits' or 'license' for more information IPython 8.6.0 -- An enhanced Interactive Python. Type '?' for help. views.py ֎෦APIΛ࣮ߦ In [1]: from django.contrib.auth.models import User
  98. ΫϥεϕʔεϏϡʔඇಉظίʔυ $ python manage.py shell Python 3.11.0 (v3.11.0:deaf509e8f, Oct 24

    2022, 14:43:23) [Clang 13.0.0 (clang-1300.0.29.30)] Type 'copyright', 'credits' or 'license' for more information IPython 8.6.0 -- An enhanced Interactive Python. Type '?' for help. views.py ֎෦APIΛ࣮ߦ In [1]: from django.contrib.auth.models import User In [2]: admin_user = User.objects.get(id=1) In [3]: admin_user Out[3]: <User: admin>
  99. ΫϥεϕʔεϏϡʔඇಉظίʔυ $ python manage.py shell Python 3.11.0 (v3.11.0:deaf509e8f, Oct 24

    2022, 14:43:23) [Clang 13.0.0 (clang-1300.0.29.30)] Type 'copyright', 'credits' or 'license' for more information IPython 8.6.0 -- An enhanced Interactive Python. Type '?' for help. views.py ֎෦APIΛ࣮ߦ In [1]: from django.contrib.auth.models import User In [2]: admin_user = User.objects.get(id=1) In [3]: admin_user Out[3]: <User: admin> In [4]: admin_user = User.objects.aget(id=1)
  100. ΫϥεϕʔεϏϡʔඇಉظίʔυ $ python manage.py shell Python 3.11.0 (v3.11.0:deaf509e8f, Oct 24

    2022, 14:43:23) [Clang 13.0.0 (clang-1300.0.29.30)] Type 'copyright', 'credits' or 'license' for more information IPython 8.6.0 -- An enhanced Interactive Python. Type '?' for help. views.py ֎෦APIΛ࣮ߦ In [1]: from django.contrib.auth.models import User In [2]: admin_user = User.objects.get(id=1) In [3]: admin_user Out[3]: <User: admin> In [4]: admin_user = User.objects.aget(id=1) In [5]: admin_user Out[5]: <coroutine object QuerySet.aget at 0x107b36110>
  101. ΫϥεϕʔεϏϡʔඇಉظίʔυ $ python manage.py shell Python 3.11.0 (v3.11.0:deaf509e8f, Oct 24

    2022, 14:43:23) [Clang 13.0.0 (clang-1300.0.29.30)] Type 'copyright', 'credits' or 'license' for more information IPython 8.6.0 -- An enhanced Interactive Python. Type '?' for help. views.py ֎෦APIΛ࣮ߦ In [1]: from django.contrib.auth.models import User In [2]: admin_user = User.objects.get(id=1) In [3]: admin_user Out[3]: <User: admin> In [4]: admin_user = User.objects.aget(id=1) In [6]: admin_user = await User.objects.aget(id=1) In [5]: admin_user Out[5]: <coroutine object QuerySet.aget at 0x107b36110>
  102. ΫϥεϕʔεϏϡʔඇಉظίʔυ $ python manage.py shell Python 3.11.0 (v3.11.0:deaf509e8f, Oct 24

    2022, 14:43:23) [Clang 13.0.0 (clang-1300.0.29.30)] Type 'copyright', 'credits' or 'license' for more information IPython 8.6.0 -- An enhanced Interactive Python. Type '?' for help. views.py ֎෦APIΛ࣮ߦ In [1]: from django.contrib.auth.models import User In [2]: admin_user = User.objects.get(id=1) In [3]: admin_user Out[3]: <User: admin> In [4]: admin_user = User.objects.aget(id=1) In [6]: admin_user = await User.objects.aget(id=1) In [7]: admin_user Out[7]: <User: admin> In [5]: admin_user Out[5]: <coroutine object QuerySet.aget at 0x107b36110>
  103. 動作 ⽐較 - ORM •̎छྨͷϞσϧ ͦΕͧΕ100,000݅ొ࿥͢Δ •ಉظɾඇಉظͰͦΕͧΕ •bulk_create/abulk_create Λ࣮ߦ •଎౓ͱ࣮ߦͷྲྀΕΛݟͯΈΔ

  104. 動作 ⽐較 - ORM •ಈ࡞؀ڥ - ϩʔΧϧ •MacBook Proʢ14Πϯνɺ2021ʣ •Apple

    M1 Pro ϝϞϦ32gb
  105. 同期処理 ⾮同期処理

  106. ΫϥεϕʔεϏϡʔಉظίʔυ class SyncOrmView(View): def get(self, request, *args, **kwargs): start =

    time() users = [] for _ in range(100_000): users.append(User(name="Taro")) snippets = [] for _ in range(100_000): snippets.append(Snippet(title="PingPong")) User.objects.bulk_create(users) Snippet.objects.bulk_create(snippets) finish = (time() - start) context = {"finish_time": finish} return render(request, "sync.html", context) views.py ORM
  107. urlpatterns = [ path('sync/', SyncOrmView.as_view(), name=‘syncbulk'), ] urls.py ΫϥεϕʔεϏϡʔಉظίʔυ ORM

  108. ࣮ߦ݁Ռ ΫϥεϕʔεϏϡʔಉظίʔυ ORM

  109. 同期処理 ⾮同期処理

  110. ΫϥεϕʔεϏϡʔಉظίʔυ class AsyncOrmView(View): async def post(self, request, *args, **kwargs): start

    = time() users = [] for _ in range(100_000): users.append(User(name="Taro")) snippets = [] for _ in range(100_000): snippets.append(Snippet(title="PingPong")) await asyncio.gather( self.check("user", User, users), self.check("snippet", Snippet, snippets) ) finish = (time() - start) context = {"finish_time": finish} return render(request, "async.html", context) async def check(self, name, model, data): print(f"start {name}") await model.objects.abulk_create(data) print(f"end {name}") views.py ORM
  111. urlpatterns = [ path('async/', AsyncOrmView.as_view(), name=‘asyncorm’), ] urls.py ΫϥεϕʔεϏϡʔಉظίʔυ ORM

  112. ࣮ߦ݁Ռ ΫϥεϕʔεϏϡʔಉظίʔυ ORM

  113. ࣮ߦ݁Ռ ΫϥεϕʔεϏϡʔಉظίʔυ ORM start user start snippets end user end

    snippets
  114. ࣮ߦ݁Ռ ΫϥεϕʔεϏϡʔಉظίʔυ ORM start user start snippets end user end

    snippets
  115. 同期 ⾮同期 •ಈ࡞ͷൺֱ •ಈ࡞͔Βɺฒߦʹ࣮ߦ͞Ε͍ͯΔ •ಈ࡞ͷൺֱ݁Ռ͸มΘΒͳ͍ •ͪΐͬͱORMͷཪଆͷ࣮૷ΛݟͯΈ·͠ΐ͏ •ಉظɿ 2.6ඵ •ඇಉظɿ 2.6ඵ

    •౰વͷಈ࡞ - ΠϯλʔϑΣʔεͷΈͷରԠ •ͳͥ͜ͷΑ͏ͳಈ͖ʹͳ͍ͬͯΔͷ͔
  116. abulk_create async def abulk_create( self, objs, batch_size=None, ignore_conflicts=False, update_conflicts=False, update_fields=None,

    unique_fields=None, ): return await sync_to_async(self.bulk_create)( objs=objs, batch_size=batch_size, ignore_conflicts=ignore_conflicts, update_conflicts=update_conflicts, update_fields=update_fields, unique_fields=unique_fields, )
  117. abulk_create async def abulk_create( self, objs, batch_size=None, ignore_conflicts=False, update_conflicts=False, update_fields=None,

    unique_fields=None, ): return await sync_to_async(self.bulk_create)( objs=objs, batch_size=batch_size, ignore_conflicts=ignore_conflicts, update_conflicts=update_conflicts, update_fields=update_fields, unique_fields=unique_fields, )
  118. aget async def aget(self, *args, **kwargs): return await sync_to_async(self.get)(*args, **kwargs)

  119. aget async def aget(self, *args, **kwargs): return await sync_to_async(self.get)(*args, **kwargs)

  120. sync_to_async •ίʔϧόοΫʹࢦఆ͞Εͨಉظؔ਺ʢ͜ͷ৔߹getʣΛඇಉظͬΆ࣮͘ߦͯ͠ฦ͢ async def aget(self, *args, **kwargs): return await sync_to_async(self.get)(*args,

    **kwargs)
  121. sync_to_async •ίʔϧόοΫʹࢦఆ͞Εͨಉظؔ਺ʢ͜ͷ৔߹getʣΛඇಉظͬΆ࣮͘ߦͯ͠ฦ͢ def sync_to_async( func=None, thread_sensitive=True, executor=None, ): if func

    is None: return lambda f: SyncToAsync( f, thread_sensitive=thread_sensitive, executor=executor, ) return SyncToAsync( func, thread_sensitive=thread_sensitive, executor=executor, ) BTHJSFGTZODQZ
  122. SyncToAsync •ThreadPoolExecutorΛར༻͠ɺಉظؔ਺ΛΠϕϯτϧʔϓ಺Ͱ࣮ߦ͢Δ class SyncToAsync: ... async def __call__(self, *args, **kwargs):

    loop = asyncio.get_running_loop() ... executor = AsyncToSync.loop_thread_executors[loop]
  123. SyncToAsync •ThreadPoolExecutorΛར༻͠ɺಉظؔ਺ΛΠϕϯτϧʔϓ಺Ͱ࣮ߦ͢Δ class SyncToAsync: ... async def __call__(self, *args, **kwargs):

    loop = asyncio.get_running_loop() ... executor = AsyncToSync.loop_thread_executors[loop] future = loop.run_in_executor( executor, functools.partial( self.thread_handler, loop, self.get_current_task(), sys.exc_info(), func, *args, **kwargs, ),
  124. SyncToAsync •ThreadPoolExecutorΛར༻͠ɺಉظؔ਺ΛΠϕϯτϧʔϓ಺Ͱ࣮ߦ͢Δ class SyncToAsync: ... async def __call__(self, *args, **kwargs):

    loop = asyncio.get_running_loop() ... executor = AsyncToSync.loop_thread_executors[loop] future = loop.run_in_executor( executor, functools.partial( self.thread_handler, loop, self.get_current_task(), sys.exc_info(), func, *args, **kwargs, ), Πϕϯτϧʔϓ಺Ͱ&YFDVUPSΛ࢖͏
  125. - ORM ⾮同期 •Ͱ͸ͳͥasyncରԠΛORMΠϯλʔϑΣʔε͸ͨ͠ͷ͔

  126. - ORM ⾮同期 •Ͱ͸ͳͥasyncରԠΛORMΠϯλʔϑΣʔε͸ͨ͠ͷ͔ •։ൃऀ͸ҙࣝ͢Δ͜ͱͳ͘ɺasync/awaitͰॻ͘͜ͱ͕Ͱ͖Δ •ඇಉظ΁ͷҠߦʹࡍ͠ɺ͋Β͔͡Ίมߋ͓ͯ͘͜͠ͱ͕Ͱ͖Δ

  127. - ORM ⾮同期 •Ͱ͸ͳͥasyncରԠΛORMΠϯλʔϑΣʔε͸ͨ͠ͷ͔ •։ൃऀ͸ҙࣝ͢Δ͜ͱͳ͘ɺasync/awaitͰॻ͘͜ͱ͕Ͱ͖Δ •ඇಉظ΁ͷҠߦʹࡍ͠ɺ͋Β͔͡Ίมߋ͓ͯ͘͜͠ͱ͕Ͱ͖Δ •ORMͷͨΊʹɺViewΛඇಉظʹ͠ͳͯ͘΋Α͍ •channels΍֎෦ϦιʔεΛར༻͢Δ৔߹ •ORM͸ඇಉظIFΛར༻͠಺෦ಉظͰಈ࡞ͤ͞Δ

  128. - ORM ⾮同期 •Ͱ͸ͳͥasyncରԠΛORMΠϯλʔϑΣʔε͸ͨ͠ͷ͔ •։ൃऀ͸ҙࣝ͢Δ͜ͱͳ͘ɺasync/awaitͰॻ͘͜ͱ͕Ͱ͖Δ •ඇಉظ΁ͷҠߦʹࡍ͠ɺ͋Β͔͡Ίมߋ͓ͯ͘͜͠ͱ͕Ͱ͖Δ •ORMͷͨΊʹɺViewΛඇಉظʹ͠ͳͯ͘΋Α͍ •channels΍֎෦ϦιʔεΛར༻͢Δ৔߹ •ORM͸ඇಉظIFΛར༻͠಺෦ಉظͰಈ࡞ͤ͞Δ

  129. DEP 0009: Async-capable Django •ʢDEP͸DjangoͷPEPʣ •Sequencing ͱͯ͠3ஈ֊ IUUQTHJUIVCDPNEKBOHPEFQTCMPCNBJOBDDFQUFEBTZODSTU

  130. DEP 0009: Async-capable Django •ʢDEP͸DjangoͷPEPʣ •Sequencing ͱͯ͠3ஈ֊ •First round (hopefully

    in 3.0) •Further individual projects •Second round (hopefully in 3.1) IUUQTHJUIVCDPNEKBOHPEFQTCMPCNBJOBDDFQUFEBTZODSTU
  131. DEP 0009: Async-capable Django •ʢDEP͸DjangoͷPEPʣ •Sequencing ͱͯ͠3ஈ֊ •First round (hopefully

    in 3.0) •Further individual projects •Second round (hopefully in 3.1) •ORM (async-wrapper interface around existing sync core) •طଘͷಉظίΞʹରԠͨ͠ඇಉظϥούʔΠϯλϑΣʔε •ORM (native async with sync wrappers for backwards compatibility) ޙํޓ׵ੑͷͨΊͷಉظϥούʔΛඋ͑ͨωΠςΟϒඇಉظ IUUQTHJUIVCDPNEKBOHPEFQTCMPCNBJOBDDFQUFEBTZODSTU
  132. DEP 0009: Async-capable Django •ʢDEP͸DjangoͷPEPʣ •Sequencing ͱͯ͠3ஈ֊ •First round (hopefully

    in 3.0) •Further individual projects •Second round (hopefully in 3.1) •ORM (async-wrapper interface around existing sync core) •طଘͷಉظίΞʹରԠͨ͠ඇಉظϥούʔΠϯλϑΣʔε •ORM (native async with sync wrappers for backwards compatibility) ޙํޓ׵ੑͷͨΊͷಉظϥούʔΛඋ͑ͨωΠςΟϒඇಉظ IUUQTHJUIVCDPNEKBOHPEFQTCMPCNBJOBDDFQUFEBTZODSTU ࣮૷ॱং͸༧ఆͲ͓Γʂ
  133. 4.1 ORM 🤔 •Θͨ͠ͷߟ͑Δཧ༝͸3ͭ

  134. 4.1 ORM 🤔 •Θͨ͠ͷߟ͑Δཧ༝͸3ͭ •ޓ׵ੑ •ޓ׵ੑΛҡ࣋͢Δํ๏Ͱ࣮૷ΛਐΊ͍ͯΔ •IF͔ΒରԠ͢Δͷ͸౰ॳͷ༧ఆͲ͓Γ •DEP͸ͦΕ΄Ͳ֬ݻͨΔ࢓༷Ͱ͸ͳͦ͞͏ʢ໋໊نଇ΋มߋʹͳͬͯΔ

  135. 4.1 ORM 🤔 •Θͨ͠ͷߟ͑Δཧ༝͸3ͭ •ޓ׵ੑ •ޓ׵ੑΛҡ࣋͢Δํ๏Ͱ࣮૷ΛਐΊ͍ͯΔ •IF͔ΒରԠ͢Δͷ͸౰ॳͷ༧ఆͲ͓Γ •ඇಉظରԠͷϝΠϯ։ൃऀͷϦιʔεෆ଍ •DEP͸ͦΕ΄Ͳ֬ݻͨΔ࢓༷Ͱ͸ͳͦ͞͏ʢ໋໊نଇ΋มߋʹͳͬͯΔ

  136. 4.1 ORM 🤔 •Θͨ͠ͷߟ͑Δཧ༝͸3ͭ •ޓ׵ੑ •ޓ׵ੑΛҡ࣋͢Δํ๏Ͱ࣮૷ΛਐΊ͍ͯΔ •ʢ૝૾ʣࢿۚ΋Өڹ͕͋Δͷ͔ʁ •IF͔ΒରԠ͢Δͷ͸౰ॳͷ༧ఆͲ͓Γ •ඇಉظରԠͷϝΠϯ։ൃऀͷϦιʔεෆ଍ •DEP

    9 / asgiref ͷ Andrew Godwin ࢯ •DEP͸ͦΕ΄Ͳ֬ݻͨΔ࢓༷Ͱ͸ͳͦ͞͏ʢ໋໊نଇ΋มߋʹͳͬͯΔ
  137. 4.1 ORM 🤔 •Θͨ͠ͷߟ͑Δཧ༝͸3ͭ •ޓ׵ੑ •ޓ׵ੑΛҡ࣋͢Δํ๏Ͱ࣮૷ΛਐΊ͍ͯΔ •ʢ૝૾ʣࢿۚ΋Өڹ͕͋Δͷ͔ʁ •IF͔ΒରԠ͢Δͷ͸౰ॳͷ༧ఆͲ͓Γ •ඇಉظରԠͷϝΠϯ։ൃऀͷϦιʔεෆ଍ 🤔

    •DEP 9 / asgiref ͷ Andrew Godwin ࢯ •PyConJP 2022ͷΩʔϊʔτͷ࿩ʢFaster C Pythonʣ💰 •DEP͸ͦΕ΄Ͳ֬ݻͨΔ࢓༷Ͱ͸ͳͦ͞͏ʢ໋໊نଇ΋มߋʹͳͬͯΔ •DEP 9 Ͱ͸ࢿۚௐୡͷ࿩΋ग़͍ͯΔ Donationͷϖʔδ΋
  138. わたしたちにできること

  139. わたしたちにできること 開発者の

  140. わたしたちにできること (経営者の⽅は… 🙏 開発者の

  141. Django 4.1 Asynchronous IUUQTEPDTEKBOHPQSPKFDUDPNFOSFMFBTFT /PUFUIBU BUUIJTTUBHF UIFVOEFSMZJOHEBUBCBTFPQFSBUJPOTSFNBJOTZODISPOPVT ͜ͷஈ֊Ͱ͸ɺجຊతͳσʔλϕʔεૢ࡞͸ಉظͷ··Ͱ͋Δ͜ͱʹ஫ҙ͍ͯͩ͘͠͞ɻ

  142. Django 4.1 Asynchronous IUUQTEPDTEKBOHPQSPKFDUDPNFOSFMFBTFT /PUFUIBU BUUIJTTUBHF UIFVOEFSMZJOHEBUBCBTFPQFSBUJPOTSFNBJOTZODISPOPVT ͜ͷஈ֊Ͱ͸ɺجຊతͳσʔλϕʔεૢ࡞͸ಉظͷ··Ͱ͋Γɺ

  143. Django 4.1 Asynchronous IUUQTEPDTEKBOHPQSPKFDUDPNFOSFMFBTFT /PUFUIBU BUUIJTTUBHF UIFVOEFSMZJOHEBUBCBTFPQFSBUJPOTSFNBJOTZODISPOPVT  XJUIDPOUSJCVUJPOTPOHPJOHUPQVTIBTZODISPOPVTTVQQPSU ͜ͷஈ֊Ͱ͸ɺجຊతͳσʔλϕʔεૢ࡞͸ಉظͷ··Ͱ͋Γɺ

  144. Django 4.1 Asynchronous IUUQTEPDTEKBOHPQSPKFDUDPNFOSFMFBTFT /PUFUIBU BUUIJTTUBHF UIFVOEFSMZJOHEBUBCBTFPQFSBUJPOTSFNBJOTZODISPOPVT  XJUIDPOUSJCVUJPOTPOHPJOHUPQVTIBTZODISPOPVTTVQQPSU ͜ͷஈ֊Ͱ͸ɺجຊతͳσʔλϕʔεૢ࡞͸ಉظͷ··Ͱ͋Γɺ

    ඇಉظͷαϙʔτΛਪਐ͢ΔͨΊͷߩݙ͕ଓ͍͍ͯ·͢ɻ
  145. •Django͸OSS

  146. •Django͸OSS •ඇಉظORMରԠʹ޲͚ͯɺߩݙ͕ߦΘΕ͍ͯΔ

  147. •Django͸OSS •ඇಉظORMରԠʹ޲͚ͯɺߩݙ͕ߦΘΕ͍ͯΔ

  148. •Django͸OSS •ඇಉظORMରԠʹ޲͚ͯɺߩݙ͕ߦΘΕ͍ͯΔ

  149. •Django͸OSS •ඇಉظORMରԠʹ޲͚ͯɺߩݙ͕ߦΘΕ͍ͯΔ •IFͷΈͷରԠͰ͋Δࠓ͸ɺ೉қ౓΋ߴ͘ͳ͘ߩݙ͠΍͍͔͢΋

  150. 謝辞 •Asynchronous ORM •https://forum.djangoproject.com/t/asynchronous-orm/5925/21 •ݱ৔Ͱ࢖͑Δ Django ͷڭՊॻ - ԣ੉ ໌ਔ(ஶ)

    •https://akiyoko.booth.pm/items/1059917 •࣮ફDjango PythonʹΑΔຊ֨WebΞϓϦέʔγϣϯ։ൃ - ࣳా ক (ஶ) •https://www.shoeisha.co.jp/book/detail/9784798153964 • Async Django: The practical guide you've been *awaiting* for by Carlton Gibson - DjangoCon Europe 2022 •https://www.youtube.com/watch?v=Lfe2zsGS0Js • Keynote: State of the Object-Relational Mapping (ORM) - Simon Charette •https://2022.djangocon.us/talks/keynote-state-of-orm/
  151. ご静聴ありがとうございました 👋