An Empirical Study of Dynamic Types for Python Projects | SpringerLink
Skip to main content

An Empirical Study of Dynamic Types for Python Projects

  • Conference paper
  • First Online:
Software Analysis, Testing, and Evolution (SATE 2018)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 11293))

Included in the following conference series:

Abstract

Python is a well-known dynamically-typed programming language. Due to its dynamic type, Python is flexible to solve complex situations. However, the use of dynamic type may cause many problems on correctness, security and performance. In this paper, we make an empirical study on the dynamic type of Python. First, we collect a dataset with 81 categories from the project list of Awesome Python. Then all Python files in this dataset are analyzed by Pysonar2. Type information is collected and saved for each identifier. Next, we proposed to recognize the dynamic type by comparing the analysis results from Pysonar2. After that, two research questions are put up to investigate the popularity of Python dynamic type in actual programming and the patterns of dynamic type for Python variables. The results show that 6.9% of identifiers in this dataset involve dynamic type and 79.7% of identifiers do not involve dynamic type. Besides, the patterns of dynamic type mainly appear among Transfer assignment methods. Finally, our results give implications such as optimization of naming space to improve the design of Python type system.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
¥17,985 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
JPY 3498
Price includes VAT (Japan)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
JPY 5719
Price includes VAT (Japan)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
JPY 7149
Price includes VAT (Japan)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

References

  1. 2017 IEEE spectrum rankings. https://spectrum.ieee.org/computing/software/the-2017-top-programming-languages

  2. Awesome Python. https://github.com/vinta/awesome-python

  3. Pysonar2. https://github.com/yinwang0/pysonar2

  4. An, J.h., Chaudhuri, A., Foster, J.S.: Static typing for ruby on rails. In: 24th IEEE/ACM International Conference on Automated Software Engineering, ASE 2009, pp. 590–594. IEEE (2009)

    Google Scholar 

  5. Anderson, C., Giannini, P., Drossopoulou, S.: Towards type inference for JavaScript. In: Black, A.P. (ed.) ECOOP 2005. LNCS, vol. 3586, pp. 428–452. Springer, Heidelberg (2005). https://doi.org/10.1007/11531142_19

    Chapter  Google Scholar 

  6. Aycock, J.: Aggressive type inference. Language 1050, 18 (2000)

    Google Scholar 

  7. Cannon, B.: Localized type inference of atomic types in Python. Ph.D. thesis. Citeseer (2005)

    Google Scholar 

  8. Chen, Z., Chen, L., Zhou, Y., Xu, Z., Chu, W.C., Xu, B.: Dynamic slicing of Python programs. In: IEEE Computer Software and Applications Conference, pp. 219–228 (2014)

    Google Scholar 

  9. Chen, Z., Ma, W., Lin, W., Chen, L., Xu, B.: Tracking down dynamic feature code changes against Python software evolution. In: Third International Conference on Trustworthy Systems and Their Applications, pp. 54–63 (2016)

    Google Scholar 

  10. Chen, Z., Ma, W., Lin, W., Chen, L., Li, Y., Xu, B.: A study on the changes of dynamic feature code when fixing bugs: towards the benefits and costs of Python dynamic features. Sci. China (Inf. Sci.) 61(1), 012107 (2018)

    Article  Google Scholar 

  11. Furr, M., An, J.D., Foster, J.S.: Profile-guided static typing for dynamic scripting languages. In: ACM SIGPLAN Notices, vol. 44, pp. 283–300. ACM (2009)

    Google Scholar 

  12. Furr, M., An, J.D., Foster, J.S., Hicks, M.: Static type inference for Ruby. In: Proceedings of the 2009 ACM Symposium on Applied Computing, pp. 1859–1866. ACM (2009)

    Google Scholar 

  13. Gorbovitski, M., Liu, Y.A., Stoller, S.D., Rothamel, T., Tekle, T.K.: Alias analysis for optimization of dynamic languages. ACM SIGPLAN Not. 45(12), 27–42 (2010)

    Article  Google Scholar 

  14. Holkner, A., Harland, J.: Evaluating the dynamic behaviour of Python applications. In: Proceedings of the Thirty-Second Australasian Conference on Computer Science, vol. 91, pp. 19–28. Australian Computer Society, Inc. (2009)

    Google Scholar 

  15. Jensen, S.H., Møller, A., Thiemann, P.: Type analysis for JavaScript. In: Palsberg, J., Su, Z. (eds.) SAS 2009. LNCS, vol. 5673, pp. 238–255. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-03237-0_17

    Chapter  Google Scholar 

  16. Kneuss, E., Suter, P., Kuncak, V.: Runtime instrumentation for precise flow-sensitive type analysis. In: Barringer, H., et al. (eds.) RV 2010. LNCS, vol. 6418, pp. 300–314. Springer, Heidelberg (2010). https://doi.org/10.1007/978-3-642-16612-9_23

    Chapter  Google Scholar 

  17. Richards, G., Lebresne, S., Burg, B., Vitek, J.: An analysis of the dynamic behavior of JavaScript programs. In: ACM SIGPLAN Notices, vol. 45, pp. 1–12. ACM (2010)

    Google Scholar 

  18. Salib, M.: Starkiller: a static type inferencer and compiler for Python. Ph.D. thesis. Massachusetts Institute of Technology (2004)

    Google Scholar 

  19. Sapra, S., Minea, M., Chaki, S., Gurfinkel, A., Clarke, E.M.: Finding errors in Python programs using dynamic symbolic execution. In: Yenigün, H., Yilmaz, C., Ulrich, A. (eds.) ICTSS 2013. LNCS, vol. 8254, pp. 283–289. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-41707-8_20

    Chapter  Google Scholar 

  20. Åkerblom, B., Stendahl, J., Tumlin, M., Wrigstad, T.: Tracing dynamic features in Python programs. In: MSR, pp. 292–295 (2014)

    Google Scholar 

  21. Thiemann, P.: Towards a type system for analyzing JavaScript programs. In: Sagiv, M. (ed.) ESOP 2005. LNCS, vol. 3444, pp. 408–422. Springer, Heidelberg (2005). https://doi.org/10.1007/978-3-540-31987-0_28

    Chapter  Google Scholar 

  22. Vitousek, M.M., Kent, A.M., Siek, J.G., Baker, J.: Design and evaluation of gradual typing for Python. In: ACM SIGPLAN Notices, vol. 50, pp. 45–56. ACM (2014)

    Google Scholar 

  23. Wang, B., Chen, L., Ma, W., Chen, Z., Xu, B.: An empirical study on the impact of Python dynamic features on change-proneness. In: The International Conference on Software Engineering and Knowledge Engineering, pp. 134–139 (2015)

    Google Scholar 

  24. Xu, Z., Zhang, X., Chen, L., Pei, K., Xu, B.: Python probabilistic type inference with natural language support. In: Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 607–618. ACM (2016)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding authors

Correspondence to Lei Xu or Baowen Xu .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Xia, X., He, X., Yan, Y., Xu, L., Xu, B. (2018). An Empirical Study of Dynamic Types for Python Projects. In: Bu, L., Xiong, Y. (eds) Software Analysis, Testing, and Evolution. SATE 2018. Lecture Notes in Computer Science(), vol 11293. Springer, Cham. https://doi.org/10.1007/978-3-030-04272-1_6

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-04272-1_6

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-04271-4

  • Online ISBN: 978-3-030-04272-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics