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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
References
2017 IEEE spectrum rankings. https://spectrum.ieee.org/computing/software/the-2017-top-programming-languages
Awesome Python. https://github.com/vinta/awesome-python
Pysonar2. https://github.com/yinwang0/pysonar2
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)
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
Aycock, J.: Aggressive type inference. Language 1050, 18 (2000)
Cannon, B.: Localized type inference of atomic types in Python. Ph.D. thesis. Citeseer (2005)
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)
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)
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)
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)
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)
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)
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)
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
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
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)
Salib, M.: Starkiller: a static type inferencer and compiler for Python. Ph.D. thesis. Massachusetts Institute of Technology (2004)
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
Åkerblom, B., Stendahl, J., Tumlin, M., Wrigstad, T.: Tracing dynamic features in Python programs. In: MSR, pp. 292–295 (2014)
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
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)
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)
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)
Author information
Authors and Affiliations
Corresponding authors
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2018 Springer Nature Switzerland AG
About this paper
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)